Exemplo n.º 1
0
 /**
  * @param string $pattern
  * @param null   $errorPhrase
  *
  * @throws ArgumentTypeException
  */
 public function __construct($pattern, $errorPhrase = null)
 {
     if (!is_string($pattern)) {
         throw new ArgumentTypeException('pattern', 'string');
     }
     $this->pattern = $pattern;
     parent::__construct($errorPhrase);
 }
Exemplo n.º 2
0
 /**
  * @param int|null  $min
  * @param int|null  $max
  * @param array $errorPhrase
  *
  * @throws ArgumentTypeException
  */
 public function __construct($min = 1, $max = null, $errorPhrase = array('MIN' => null, 'MAX' => null))
 {
     if ($min !== null) {
         if (!is_int($min)) {
             throw new ArgumentTypeException('min', 'integer');
         }
         $this->min = $min;
     }
     if ($max !== null) {
         if (!is_int($max)) {
             throw new ArgumentTypeException('max', 'integer');
         }
         $this->max = $max;
     }
     if (!empty($errorPhrase['MIN'])) {
         $this->errorPhraseMin = $errorPhrase['MIN'];
     }
     if (!empty($errorPhrase['MAX'])) {
         $this->errorPhraseMax = $errorPhrase['MAX'];
     }
     parent::__construct();
 }