Skip to content

Commit

Permalink
Merge pull request #5 from lexustec/master
Browse files Browse the repository at this point in the history
Update Settings.php
  • Loading branch information
noximo authored Apr 16, 2020
2 parents f1fdc8d + 1878485 commit 34fe510
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ final class Settings
* @var int
*/
private $offset = 2;

/**
* @var int
*/
private $decimals = 2;

/**
* @var string
Expand Down Expand Up @@ -50,9 +55,10 @@ public function __construct()
{
$this->format = function ($x, self $settings) {
$padding = $settings->getPadding();
$decimals = $settings->getDecimals();
$paddingLength = \strlen($padding);

return substr($padding . round($x, 2), -$paddingLength);
return substr($padding . round($x, $decimals), -$paddingLength);
};
}

Expand All @@ -73,6 +79,18 @@ public function setPadding(int $length, ?string $char = null): self
return $this;
}

public function getDecimals(): int
{
return $this->decimals;
}

public function setDecimals(int $decimals): self
{
$this->decimals = $decimals;

return $this;
}

public function getHeight(): ?int
{
return $this->height;
Expand Down

0 comments on commit 34fe510

Please sign in to comment.