Inheritance: extends Exception
Esempio n. 1
0
 /**
  * @param string $code
  *
  * @throws InvalidArgumentException
  */
 public function __construct(string $code)
 {
     if (empty($code)) {
         throw InvalidArgumentException::emptySku();
     }
     $this->code = $code;
 }
Esempio n. 2
0
 /**
  * @param int    $amount    Amount, expressed in the smallest units of $currency (eg cents)
  * @param string $currency
  * @param int    $precision used to calculate float value, 10000 cents / 100 = 100.00
  *
  * @throws InvalidArgumentException
  */
 public function __construct(int $amount, string $currency, int $precision = self::DEFAULT_PRECISION)
 {
     if ($amount < 0) {
         throw InvalidArgumentException::negativePriceAmount($amount);
     }
     if ($precision < 0) {
         throw InvalidArgumentException::negativePricePrecision($precision);
     }
     if (!Currencies::isValid($currency)) {
         throw InvalidArgumentException::invalidCurrency($currency);
     }
     $this->amount = $amount;
     $this->currency = $currency;
     $this->precision = $precision;
 }
Esempio n. 3
0
 function it_throw_exception_when_currency_is_not_known()
 {
     $this->shouldThrow(InvalidArgumentException::invalidCurrency('Unknown'))->during('__construct', [1000, 'Unknown', 100]);
 }