/** * Ensures that getMessages() returns expected default value * * @return void */ public function testGetMessages() { $this->assertEquals(array(), $this->validator->getMessages()); }
/** * 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; }