Source of file Validator.php
Size: 1,734 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Log/Filter/Validator.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Log\Filter; use Traversable; use Zend\Log\Exception; use Zend\Validator\ValidatorInterface as ZendValidator; class Validator implements FilterInterface { /** * Regex to match * * @var ZendValidator */ protected $validator; /** * Filter out any log messages not matching the validator * * @param ZendValidator|array|Traversable $validator * @throws Exception\InvalidArgumentException * @return Validator */ public function __construct($validator) { if ($validator instanceof Traversable) { $validator = iterator_to_array($validator); } if (is_array($validator)) { $validator = isset($validator['validator']) ? $validator['validator'] : null; } if (!$validator instanceof ZendValidator) { throw new Exception\InvalidArgumentException(sprintf( 'Parameter of type %s is invalid; must implement Zend\Validator\ValidatorInterface', (is_object($validator) ? get_class($validator) : gettype($validator)) )); } $this->validator = $validator; } /** * Returns TRUE to accept the message, FALSE to block it. * * @param array $event event data * @return bool */ public function filter(array $event) { return $this->validator->isValid($event['message']); } } |