Пример #1
0
 /**
  * @ZF-4352
  */
 public function testNonStringValidation()
 {
     $this->assertFalse($this->validator->isValid(array(1 => 1)));
 }
Пример #2
0
 /**
  * Set colors
  *
  * @param unknown $colors
  * @throws Exception\InvalidArgumentException
  * @return \PlaceholdIt\View\Helper\PlaceholdIt
  * @author William D. Urbano <*****@*****.**> "http://williamurbano.com.br"
  */
 public function setColors($colors)
 {
     $hexValidator = new Validator\Hex();
     if (is_array($colors)) {
         $count = 0;
         foreach ($colors as &$c) {
             $count++;
             $c = (new I18n\Filter\Alnum())->filter($c);
             if (!$hexValidator->isValid($c)) {
                 foreach ($hexValidator->getMessages() as $message) {
                     throw new Exception\InvalidArgumentException($message);
                 }
             }
         }
     } elseif (is_string($colors)) {
         $colors = (new I18n\Filter\Alnum())->filter($colors);
         if (!$hexValidator->isValid($colors)) {
             foreach ($hexValidator->getMessages() as $message) {
                 throw new Exception\InvalidArgumentException($message);
             }
         }
         $colors = array($colors);
     } elseif (is_numeric($colors)) {
         $colors = (new Filter\Digits())->filter($colors);
         if (!$hexValidator->isValid($colors)) {
             foreach ($hexValidator->getMessages() as $message) {
                 throw new Exception\InvalidArgumentException($message);
             }
         }
         $colors = array($colors);
     } else {
         $colors = array();
     }
     $this->colors = $colors;
     return $this;
 }