Skip to content

Commit

Permalink
added UnexpectedAmountException class
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Jul 27, 2022
1 parent daf8ca8 commit cbc66d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/Exceptions/UnexpectedAmountException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Akaunting\Money\Exceptions;

use UnexpectedValueException;

class UnexpectedAmountException extends UnexpectedValueException
{
//
}
8 changes: 4 additions & 4 deletions src/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Akaunting\Money;

use Akaunting\Money\Casts\MoneyCast;
use Akaunting\Money\Exceptions\UnexpectedAmountException;
use BadFunctionCallException;
use Closure;
use Illuminate\Contracts\Database\Eloquent\Castable;
Expand All @@ -13,7 +14,6 @@
use InvalidArgumentException;
use JsonSerializable;
use OutOfBoundsException;
use UnexpectedValueException;

/**
* Class Money.
Expand Down Expand Up @@ -204,7 +204,7 @@ class Money implements Arrayable, Castable, Jsonable, JsonSerializable, Renderab
/**
* Create a new instance.
*
* @throws UnexpectedValueException
* @throws UnexpectedAmountException
*/
public function __construct(mixed $amount, Currency $currency, bool $convert = false)
{
Expand All @@ -215,7 +215,7 @@ public function __construct(mixed $amount, Currency $currency, bool $convert = f
/**
* parseAmount.
*
* @throws UnexpectedValueException
* @throws UnexpectedAmountException
*/
protected function parseAmount(mixed $amount, bool $convert = false): int|float
{
Expand All @@ -234,7 +234,7 @@ protected function parseAmount(mixed $amount, bool $convert = false): int|float
return $this->convertAmount($amount->getAmount(), $convert);
}

throw new UnexpectedValueException('Invalid amount "' . $amount . '"');
throw new UnexpectedAmountException('Invalid amount "' . $amount . '"');
}

protected function parseAmountFromCallable(mixed $amount): mixed
Expand Down

0 comments on commit cbc66d1

Please sign in to comment.