ImperialMassFormatter
February 4, 2026 ยท View on GitHub
The ImperialMassFormatter promotes imperial mass values between oz, lb, st, and ton.
- Non-numeric input is returned unchanged.
- Promotion is based on magnitude.
- Output uses symbols only (no spaces), e.g.
1lb,8oz.
Usage
use Respect\StringFormatter\ImperialMassFormatter;
$formatter = new ImperialMassFormatter('oz');
echo $formatter->format('16');
// Outputs: 1lb
API
ImperialMassFormatter::__construct
__construct(string $unit)
The $unit is the input unit (the unit you are providing values in).
Accepted units: oz, lb, st, ton.
Notes
tonrepresents the imperial long ton (2240lb).