Example #1
0
 public function __construct(array $options = [])
 {
     parent::__construct($options);
     $options = $this->getOptions();
     if (!is_bool($options['trim'])) {
         throw new \Gajus\Vlad\Exception\InvalidArgumentException('Boolean property assigned non-boolean value.');
     }
 }
Example #2
0
File: Date.php Project: gajus/vlad
 public function __construct(array $options = [])
 {
     parent::__construct($options);
     $options = $this->getOptions();
     if (!isset($options['format'])) {
         throw new \Gajus\Vlad\Exception\InvalidArgumentException('"format" property is required.');
     }
 }
Example #3
0
 public function __construct(array $options = [])
 {
     parent::__construct($options);
     $options = $this->getOptions();
     if (!isset($options['length'])) {
         throw new \Gajus\Vlad\Exception\InvalidArgumentException('"length" option is required.');
     }
     if (!ctype_digit((string) $options['length'])) {
         throw new \Gajus\Vlad\Exception\InvalidArgumentException('"length" option must be a whole number.');
     }
 }
Example #4
0
 public function __construct(array $options = [])
 {
     parent::__construct($options);
     $options = $this->getOptions();
     if (!isset($options['range'])) {
         throw new \Gajus\Vlad\Exception\InvalidArgumentException('"range" option is required.');
     }
     if (!is_numeric($options['range'])) {
         throw new \Gajus\Vlad\Exception\InvalidArgumentException('Minimum boundary option must be numeric.');
     }
 }
Example #5
0
File: Regex.php Project: gajus/vlad
 public function __construct(array $options = [])
 {
     parent::__construct($options);
     $options = $this->getOptions();
     if (!isset($options['pattern'])) {
         throw new \Gajus\Vlad\Exception\InvalidArgumentException('"pattern" property is required.');
     }
     if (@preg_match($options['pattern'], 'test') === false) {
         throw new \Gajus\Vlad\Exception\InvalidArgumentException('Pattern "' . $options['pattern'] . '" failed (' . array_flip(get_defined_constants(true)['pcre'])[preg_last_error()] . ').');
     }
 }
Example #6
0
File: In.php Project: gajus/vlad
 public function __construct(array $options = [])
 {
     parent::__construct($options);
     $options = $this->getOptions();
     if (!isset($options['haystack'])) {
         throw new \Gajus\Vlad\Exception\InvalidArgumentException('"haystack" option is missing.');
     } else {
         if (!is_array($options['haystack'])) {
             throw new \Gajus\Vlad\Exception\InvalidArgumentException('"haystack" option must be an array.');
         }
     }
     if (!is_bool($options['strict']) || !is_bool($options['c14n'])) {
         throw new \Gajus\Vlad\Exception\InvalidArgumentException('Boolean property assigned non-boolean value.');
     }
 }