We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9dc7fc1 commit 7018e84Copy full SHA for 7018e84
src/Unit.php
@@ -434,17 +434,20 @@ public function substract()
434
*/
435
public function format($precision = 3, $addSymbol = true)
436
{
437
- $symbol = $this->getSymbol();
+ $format = '%02.' . $precision . 'f';
438
439
- if (!empty($symbol)) {
440
- $format = '%02.' . $precision . 'f %s';
+ if (!$addSymbol) {
+ return sprintf($format, $this->getValue());
441
+ }
442
- return sprintf($format, $this->getValue(), $symbol);
443
- } else {
444
- $format = '%02.' . $precision . 'f';
+ $symbol = $this->getSymbol();
445
+ if (empty($symbol)) {
446
return sprintf($format, $this->getValue());
447
}
448
+
449
+ $format .= ' %s';
450
+ return sprintf($format, $this->getValue(), $symbol);
451
452
453
/**
0 commit comments