Skip to content

Commit cbc66d1

Browse files
committed
added UnexpectedAmountException class
1 parent daf8ca8 commit cbc66d1

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Akaunting\Money\Exceptions;
4+
5+
use UnexpectedValueException;
6+
7+
class UnexpectedAmountException extends UnexpectedValueException
8+
{
9+
//
10+
}

src/Money.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Akaunting\Money;
44

55
use Akaunting\Money\Casts\MoneyCast;
6+
use Akaunting\Money\Exceptions\UnexpectedAmountException;
67
use BadFunctionCallException;
78
use Closure;
89
use Illuminate\Contracts\Database\Eloquent\Castable;
@@ -13,7 +14,6 @@
1314
use InvalidArgumentException;
1415
use JsonSerializable;
1516
use OutOfBoundsException;
16-
use UnexpectedValueException;
1717

1818
/**
1919
* Class Money.
@@ -204,7 +204,7 @@ class Money implements Arrayable, Castable, Jsonable, JsonSerializable, Renderab
204204
/**
205205
* Create a new instance.
206206
*
207-
* @throws UnexpectedValueException
207+
* @throws UnexpectedAmountException
208208
*/
209209
public function __construct(mixed $amount, Currency $currency, bool $convert = false)
210210
{
@@ -215,7 +215,7 @@ public function __construct(mixed $amount, Currency $currency, bool $convert = f
215215
/**
216216
* parseAmount.
217217
*
218-
* @throws UnexpectedValueException
218+
* @throws UnexpectedAmountException
219219
*/
220220
protected function parseAmount(mixed $amount, bool $convert = false): int|float
221221
{
@@ -234,7 +234,7 @@ protected function parseAmount(mixed $amount, bool $convert = false): int|float
234234
return $this->convertAmount($amount->getAmount(), $convert);
235235
}
236236

237-
throw new UnexpectedValueException('Invalid amount "' . $amount . '"');
237+
throw new UnexpectedAmountException('Invalid amount "' . $amount . '"');
238238
}
239239

240240
protected function parseAmountFromCallable(mixed $amount): mixed

0 commit comments

Comments
 (0)