Skip to content

Commit

Permalink
Trim format (#22)
Browse files Browse the repository at this point in the history
* test currency format + trim

* add decimals

* fix test for decimals
  • Loading branch information
TomK authored Mar 5, 2020
1 parent 47b60be commit 6578dab
Show file tree
Hide file tree
Showing 181 changed files with 918 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/Currency/AbstractCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,20 @@ public function getUSDAverageValue($value)

public function format($amount, $showSymbol = true, $showCode = false)
{
return str_replace(
[
'{symbol}',
'{number}',
'{code}',
],
[
$showSymbol ? $this->getSymbol() : '',
$this->numberFormat($amount),
$showCode ? $this->getCode() : '',
],
$this->_getRenderFormat($amount)
return trim(
str_replace(
[
'{symbol}',
'{number}',
'{code}',
],
[
$showSymbol ? $this->getSymbol() : '',
$this->numberFormat($amount),
$showCode ? $this->getCode() : '',
],
$this->_getRenderFormat($amount)
)
);
}

Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/AEDCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class AEDCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'AED';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/AFNCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class AFNCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return '؋';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/ALLCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class ALLCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'Lek';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/AMDCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class AMDCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'AMD';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/ANGCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class ANGCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'ƒ';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/AOACurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class AOACurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'AOA';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/ARSCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class ARSCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return '$';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/ATSCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class ATSCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'ATS';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/AUDCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class AUDCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return '$';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/AWGCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class AWGCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'ƒ';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/AZNCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class AZNCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'ман';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BAMCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BAMCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'KM';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BBDCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BBDCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return '$';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BDTCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BDTCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'BDT';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BEFCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BEFCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'BEF';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BGNCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BGNCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'лв';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BHDCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BHDCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 3;
}

public function getSymbol()
{
return 'BHD';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BIFCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BIFCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 0;
}

public function getSymbol()
{
return 'BIF';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BMDCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BMDCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return '$';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BNDCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BNDCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return '$';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BOBCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BOBCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return '$b';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BRLCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BRLCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'R$';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BSDCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BSDCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return '$';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BTNCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BTNCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'BTN';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BWPCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BWPCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'P';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BYRCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BYRCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 0;
}

public function getSymbol()
{
return 'p.';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/BZDCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class BZDCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'BZ$';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/CADCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class CADCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return '$';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/CDFCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class CDFCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'CDF';
Expand Down
5 changes: 5 additions & 0 deletions src/Currency/Currencies/CHFCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class CHFCurrency extends AbstractCurrency
{
public function getDecimalCount()
{
return 2;
}

public function getSymbol()
{
return 'CHF';
Expand Down
Loading

0 comments on commit 6578dab

Please sign in to comment.