Esempio n. 1
0
 function __construct(...$args)
 {
     parent::__construct(...$args);
     if (isset($this->props)) {
         if (!is_array($this->props)) {
             throw new \InvalidArgumentException();
         }
         foreach ($this->props as $p => &$c) {
             if (!is_string($p)) {
                 throw new \InvalidArgumentException();
             }
             if ($c !== true) {
                 if (!is_array($c) && !$c instanceof \Traversable) {
                     $c = [$c];
                 }
                 foreach ($c as $check) {
                     if (!$check instanceof \Fulfil\CheckInterface) {
                         throw new \InvalidArgumentException("Invalid check type for property {$p}. Expected \\Fulfil\\CheckInterface, found " . Func::getType($check));
                     }
                 }
             }
         }
         unset($c);
     }
 }
Esempio n. 2
0
 function __construct(...$args)
 {
     parent::__construct(...$args);
     if ($this->trueValues || $this->falseValues) {
         $this->allowLoose = true;
     }
     if ($this->trueValues) {
         foreach ($this->trueValues as &$value) {
             if (is_string($value)) {
                 $value = mb_strtolower(\Normalizer::normalize($value));
             } elseif (!is_scalar($value)) {
                 throw new \InvalidArgumentException();
             }
         }
         unset($value);
     }
     if ($this->falseValues) {
         foreach ($this->falseValues as &$value) {
             if (is_string($value)) {
                 $value = mb_strtolower(\Normalizer::normalize($value));
             } elseif (!is_scalar($value)) {
                 throw new \InvalidArgumentException();
             }
         }
         unset($value);
     }
 }
Esempio n. 3
0
 public function __construct(...$args)
 {
     parent::__construct(...$args);
     if ($this->casing && !in_array($this->casing, self::$validCasing)) {
         throw new \InvalidArgumentException("Casing must be one of " . implode(', ', self::$validCasing));
     }
 }
Esempio n. 4
0
 function __construct(...$args)
 {
     parent::__construct(...$args);
     if ($this->divisibleBy !== null) {
         $this->divisibleBy = BigNumbers\Decimal::create($this->divisibleBy);
         if (!$this->divisibleBy->isPositive()) {
             throw new \InvalidArgumentException("divisibleBy must be a positive integer");
         }
     }
 }
Esempio n. 5
0
 function __construct(...$args)
 {
     parent::__construct(...$args);
     if ($this->min !== null && $this->max !== null && $this->min > $this->max) {
         throw new \InvalidArgumentException();
     }
     if ($this->divisibleBy !== null && $this->divisibleBy <= 0) {
         throw new \InvalidArgumentException("divisibleBy must be a positive integer");
     }
 }
Esempio n. 6
0
 public function __construct(...$args)
 {
     parent::__construct(...$args);
     if (!is_array($this->formats)) {
         $this->formats = [$this->formats];
     }
     if (is_string($this->tz)) {
         $this->tz = new \DateTimeZone($this->tz);
     }
 }
Esempio n. 7
0
 function __construct(...$args)
 {
     parent::__construct(...$args);
     if ($this->min !== null && is_string($this->min)) {
         $this->min = \DateTime::createFromFormat(\DateTime::ISO8601, $this->min);
     }
     if ($this->max !== null && is_string($this->max)) {
         $this->max = \DateTime::createFromFormat(\DateTime::ISO8601, $this->max);
     }
 }
Esempio n. 8
0
 function __construct(...$args)
 {
     parent::__construct(...$args);
     $d = new \DateTime();
     foreach ($this->dateFormats as $fmt) {
         $test = $d->format($fmt);
         if ($test === false || $test === $fmt) {
             throw new \InvalidArgumentException("Invalid date format '{$fmt}'");
         }
     }
     if ($this->tz === null) {
         $this->tz = new \DateTimeZone(date_default_timezone_get());
     } elseif (!$this->tz instanceof \DateTimeZone) {
         $this->tz = new \DateTimeZone($this->tz);
     }
 }