Skip to content

Commit

Permalink
Merge a3f90c5 into 46c4ce6
Browse files Browse the repository at this point in the history
  • Loading branch information
solodkiy committed Oct 17, 2020
2 parents 46c4ce6 + a3f90c5 commit a3deecf
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/Exception/CurrencyConversionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Exception thrown when an exchange rate is not available.
*/
class CurrencyConversionException extends MoneyException
class CurrencyConversionException extends \RuntimeException implements MoneyException
{
/**
* @var string
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/MoneyException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Brick\Money\Exception;

/**
* Base class for money exceptions.
* Interface for money exceptions.
*/
abstract class MoneyException extends \Exception
interface MoneyException extends \Throwable
{
}
2 changes: 1 addition & 1 deletion src/Exception/MoneyMismatchException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Exception thrown when a money is not in the expected currency or context.
*/
class MoneyMismatchException extends MoneyException
class MoneyMismatchException extends \DomainException implements MoneyException
{
/**
* @param Currency $expected
Expand Down
84 changes: 42 additions & 42 deletions src/Exception/UnknownCurrencyException.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
<?php

declare(strict_types=1);

namespace Brick\Money\Exception;

/**
* Exception thrown when attempting to create a Currency from an unknown currency code.
*/
class UnknownCurrencyException extends MoneyException
{
/**
* @param string|int $currencyCode
*
* @return UnknownCurrencyException
*/
public static function unknownCurrency($currencyCode) : self
{
return new self('Unknown currency code: ' . $currencyCode);
}

/**
* @param string $countryCode
*
* @return UnknownCurrencyException
*/
public static function noCurrencyForCountry(string $countryCode) : self
{
return new self('No currency found for country ' . $countryCode);
}

/**
* @param string $countryCode
* @param array $currencyCodes
*
* @return UnknownCurrencyException
*/
public static function noSingleCurrencyForCountry(string $countryCode, array $currencyCodes) : self
{
return new self('No single currency for country ' . $countryCode . ': ' . implode(', ', $currencyCodes));
}
}
<?php

declare(strict_types=1);

namespace Brick\Money\Exception;

/**
* Exception thrown when attempting to create a Currency from an unknown currency code.
*/
class UnknownCurrencyException extends \DomainException implements MoneyException
{
/**
* @param string|int $currencyCode
*
* @return UnknownCurrencyException
*/
public static function unknownCurrency($currencyCode) : self
{
return new self('Unknown currency code: ' . $currencyCode);
}

/**
* @param string $countryCode
*
* @return UnknownCurrencyException
*/
public static function noCurrencyForCountry(string $countryCode) : self
{
return new self('No currency found for country ' . $countryCode);
}

/**
* @param string $countryCode
* @param array $currencyCodes
*
* @return UnknownCurrencyException
*/
public static function noSingleCurrencyForCountry(string $countryCode, array $currencyCodes) : self
{
return new self('No single currency for country ' . $countryCode . ': ' . implode(', ', $currencyCodes));
}
}

0 comments on commit a3deecf

Please sign in to comment.