Source of file NumberOfParameterFilter.php
Size: 1,423 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Stdlib/Hydrator/Filter/NumberOfParameterFilter.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | <?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\Stdlib\Hydrator\Filter; use ReflectionException; use ReflectionMethod; use Zend\Stdlib\Exception\InvalidArgumentException; class NumberOfParameterFilter implements FilterInterface { /** * The number of parameters beeing accepted * @var int */ protected $numberOfParameters = null; /** * @param int $numberOfParameters Number of accepted parameters */ public function __construct($numberOfParameters = 0) { $this->numberOfParameters = 0; } /** * @param string $property the name of the property * @return bool * @throws InvalidArgumentException */ public function filter($property) { try { $reflectionMethod = new ReflectionMethod($property); } catch (ReflectionException $exception) { throw new InvalidArgumentException( "Method $property doesn't exist" ); } if ($reflectionMethod->getNumberOfParameters() !== $this->numberOfParameters) { return false; } return true; } } |