Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Dec 14, 2021
1 parent 4974c0d commit 97e6ae1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 30 deletions.
15 changes: 0 additions & 15 deletions phpstan-baseline.neon
@@ -1,17 +1,2 @@
parameters:
ignoreErrors:
-
message: "#^Method Duit\\\\MYR\\:\\:getClosestAcceptedCashAmount\\(\\) should return int but returns float\\|int\\.$#"
count: 1
path: src/MYR.php

-
message: "#^Parameter \\#1 \\$amount of class Money\\\\Money constructor expects int\\|\\(string&numeric\\), int\\|string given\\.$#"
count: 1
path: src/MYR.php

-
message: "#^Parameter \\#1 \\$number of static method Money\\\\Number\\:\\:fromString\\(\\) expects string, int\\|string given\\.$#"
count: 1
path: src/MYR.php

13 changes: 7 additions & 6 deletions src/Concerns/Cash.php
Expand Up @@ -9,8 +9,8 @@ trait Cash
{
/**
* Get formatted amount.
*
* @return numeric-string
*
* @return numeric-string|non-empty-string
*/
public function amount(): string
{
Expand All @@ -19,8 +19,8 @@ public function amount(): string

/**
* Get formatted cash.
*
* @return numeric-string
*
* @return numeric-string|non-empty-string
*/
public function cashAmount(): string
{
Expand All @@ -31,7 +31,7 @@ public function cashAmount(): string

/**
* Get amount for cash.
*
*
* @return numeric-string
*/
public function getCashAmount(): string
Expand All @@ -48,7 +48,8 @@ public function getCashAmount(): string
*/
protected function getClosestAcceptedCashAmount($amount): int
{
$value = Number::fromString($amount)->getIntegerPart();
/** @var int $value */
$value = Number::fromString((string) $amount)->getIntegerPart();
$cent = $amount % 5;

if ($cent <= 2) {
Expand Down
14 changes: 7 additions & 7 deletions src/Concerns/Tax.php
Expand Up @@ -59,8 +59,8 @@ public static function withoutTax($amount)

/**
* Get formatted amount with GST.
*
* @return numeric-string
*
* @return numeric-string|non-empty-string
*/
public function amountWithTax(): string
{
Expand All @@ -71,8 +71,8 @@ public function amountWithTax(): string

/**
* Get formatted cash with GST.
*
* @return numeric-string
*
* @return numeric-string|non-empty-string
*/
public function cashAmountWithTax(): string
{
Expand Down Expand Up @@ -115,7 +115,7 @@ final public function hasTax(): bool

/**
* Get GST amount.
*
*
* @return numeric-string
*/
public function getTaxAmount(): string
Expand All @@ -129,7 +129,7 @@ public function getTaxAmount(): string

/**
* Returns the value represented by this object with Tax.
*
*
* @return numeric-string
*/
public function getAmountWithTax(): string
Expand All @@ -143,7 +143,7 @@ public function getAmountWithTax(): string

/**
* Get amount for cash with Tax.
*
*
* @return numeric-string
*/
public function getCashAmountWithTax(): string
Expand Down
4 changes: 2 additions & 2 deletions src/MYR.php
Expand Up @@ -78,7 +78,7 @@ public static function parse($value)

/**
* Returns the value represented by this object.
*
*
* @return numeric-string
*/
public function getAmount(): string
Expand Down Expand Up @@ -157,7 +157,7 @@ public function __call(string $method, array $parameters)
/**
* Build money object.
*
* @param int|string $amount
* @param int|numeric-string $amount
*/
protected static function asMoney($amount): Money
{
Expand Down

0 comments on commit 97e6ae1

Please sign in to comment.