Skip to content

Commit

Permalink
only append code if we specifically want to add it (removes spacing f… (
Browse files Browse the repository at this point in the history
#27)

* only append code if we specifically want to add it (removes spacing form the right)

* phpunit fix

* Lower phpunit version

* remove silly

* default to true, pass through

* Revert change as standard

* && has code
  • Loading branch information
MrEssex authored Feb 29, 2024
1 parent 1356352 commit b8dce2c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ jobs:
with:
configuration: ./phpunit.xml
php_version: 7.4
version: 8.5
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"php": ">=7.4"
},
"require-dev": {
"phpunit/phpunit": "~8.0"
"phpunit/phpunit": "^8.0"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 9 additions & 3 deletions src/Currency/AbstractCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,21 @@ public function format($amount, $showSymbol = true, $showCode = false)
$this->numberFormat(abs($amount)),
$showCode ? $this->getCode() : '',
],
$this->_getRenderFormat($amount)
$this->_getRenderFormat($amount, $showCode && $this->getCode())
)
);
}

protected function _getRenderFormat($amount)
protected function _getRenderFormat($amount, $showCode = true)
{
$return = $amount < 0 ? '-' : '';
$return .= '{symbol}{number} {code}';
$return .= '{symbol}{number}';

if($showCode)
{
$return .= ' {code}';
}

return $return;
}

Expand Down
10 changes: 7 additions & 3 deletions src/Currency/Currencies/EURCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return '';
Expand Down Expand Up @@ -54,7 +54,7 @@ public function setCountry($code)
return $this;
}

protected function _getRenderFormat($amount)
protected function _getRenderFormat($amount, $showCode = true)
{
switch($this->_countryCode)
{
Expand All @@ -65,7 +65,11 @@ protected function _getRenderFormat($amount)
case CountryCode::CODE_PT;
case CountryCode::CODE_ES;
$return = $amount < 0 ? '-' : '';
$return .= '{number} {symbol} {code}';
$return .= '{number} {symbol}';
if($showCode)
{
$return .= ' {code}';
}
return $return;
}
return parent::_getRenderFormat($amount);
Expand Down

0 comments on commit b8dce2c

Please sign in to comment.