diff --git a/composer.json b/composer.json index 48d67e2..057098e 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.1-dev" } }, "minimum-stability": "dev" diff --git a/phpunit.xml b/phpunit.xml index 4931653..e0cd45a 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,7 +7,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="true" verbose="true" > diff --git a/src/MYR.php b/src/MYR.php index d803d2e..5d1512d 100644 --- a/src/MYR.php +++ b/src/MYR.php @@ -7,6 +7,7 @@ use Money\MoneyFormatter; use BadMethodCallException; use Money\Currencies\ISOCurrencies; +use Money\Parser\DecimalMoneyParser; use Money\Formatter\DecimalMoneyFormatter; class MYR implements Contracts\Money, \JsonSerializable @@ -49,6 +50,22 @@ public static function given($amount) return static::withoutVat($amount); } + /** + * Parse value as ringgit. + * + * @param string $amount + * + * @return static + */ + public static function parse(string $amount) + { + $parser = new DecimalMoneyParser(new ISOCurrencies()); + + return static::given( + $parser->parse($amount, 'MYR')->getAmount() + ); + } + /** * Returns the value represented by this object. * diff --git a/tests/MYRTest.php b/tests/MYRTest.php index 9477a6c..0e3397d 100644 --- a/tests/MYRTest.php +++ b/tests/MYRTest.php @@ -13,6 +13,14 @@ public function it_can_be_initiated_using_given() $this->assertSame('1000', $money->add($money)->getAmount()); } + /** @test */ + public function it_can_be_initiated_using_parse() + { + $money = MYR::parse('2.50'); + + $this->assertSame('500', $money->add($money)->getAmount()); + } + /** @test */ public function it_can_be_get_currency_information() {