Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikuscs committed May 27, 2024
2 parents 1a7ea82 + 7f1b6b3 commit e327e24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
13 changes: 2 additions & 11 deletions src/Concerns/HasWallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,10 @@ public function credit(float|int|string $amount, array $meta = [], ?string $endp

/**
* Credit the user quietly without exceptions
* @param float|int|string $amount
* @param array $meta
* @param string|null $endpoint
* @return bool
*/
public function creditQuietly(float|int|string $amount, array $meta = [], ?string $endpoint = null): bool
{
try{
try {
return $this->wallet()->credit(
amount: $amount,
meta: $meta,
Expand Down Expand Up @@ -123,15 +119,10 @@ public function debit(float|int|string $amount, array $meta = [], ?string $endpo

/**
* Attempts to Debit the user quietly without exceptions
*
* @param float|int|string $amount
* @param array $meta
* @param string|null $endpoint
* @return bool
*/
public function debitQuietly(float|int|string $amount, array $meta = [], ?string $endpoint = null): bool
{
try{
try {
return $this->wallet()->debit(
amount: $amount,
meta: $meta,
Expand Down
20 changes: 4 additions & 16 deletions src/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,43 +258,35 @@ public function compare(float|int|string $first, float|int|string $second): int
/**
* Check if its zero
*
* @param float|int|string $number
* @param int|null $scale
* @return bool
* @throws DivisionByZeroException
* @throws NumberFormatException
* @throws RoundingNecessaryException
*/
public function isZero(float|int|string $number, ?int $scale = null): bool
public function isZero(float|int|string $number, ?int $scale = null): bool
{
return BigDecimal::of($number)
->toScale($scale ?? $this->floatScale, RoundingMode::DOWN)
->isZero();
}

/**
* @param float|int|string $number
* @param int|null $scale
* @return bool
* @throws DivisionByZeroException
* @throws NumberFormatException
* @throws RoundingNecessaryException
*/
public function isNotZero(float|int|string $number, ?int $scale = null): bool
public function isNotZero(float|int|string $number, ?int $scale = null): bool
{
return ! $this->isZero($number, $scale);
}

/**
* Returns the representation of the number as a string
* @param float|int|string $number
* @param int|null $scale
* @return BigDecimal
*
* @throws DivisionByZeroException
* @throws NumberFormatException
* @throws RoundingNecessaryException
*/
public function toToNumber(float|int|string $number, ?int $scale = null): BigDecimal
public function toToNumber(float|int|string $number, ?int $scale = null): BigDecimal
{
return BigDecimal::of($number)
->toScale($scale ?? $this->floatScale, RoundingMode::DOWN);
Expand All @@ -303,10 +295,6 @@ public function toToNumber(float|int|string $number, ?int $scale = null): BigDe
/**
* Check if two numbers are equal
*
* @param float|int|string $first
* @param float|int|string $second
* @param int|null $scale
* @return bool
* @throws DivisionByZeroException
* @throws NumberFormatException
* @throws RoundingNecessaryException
Expand Down

0 comments on commit e327e24

Please sign in to comment.