isValid() 공개 정적인 메소드

public static isValid ( string $code ) : boolean
$code string
리턴 boolean
예제 #1
0
파일: Cart.php 프로젝트: dumplie/dumplie
 /**
  * @param CartId $cartId
  * @param string $currency
  *
  * @throws InvalidArgumentException
  */
 public function __construct(CartId $cartId, string $currency)
 {
     if (!Currencies::isValid($currency)) {
         throw InvalidArgumentException::invalidCurrency($currency);
     }
     $this->id = $cartId;
     $this->items = [];
     $this->currency = $currency;
 }
예제 #2
0
파일: Price.php 프로젝트: dumplie/dumplie
 /**
  * @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;
 }
예제 #3
0
 function test_ignoring_lowercase_in_currency_code_validation()
 {
     $this->assertTrue(Currencies::isValid("pln"));
 }