TYPO3  7.6
CustomFilterIterator.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Symfony\Component\Finder\Iterator;
13 
23 {
24  private $filters = array();
25 
34  public function __construct(\Iterator $iterator, array $filters)
35  {
36  foreach ($filters as $filter) {
37  if (!is_callable($filter)) {
38  throw new \InvalidArgumentException('Invalid PHP callback.');
39  }
40  }
41  $this->filters = $filters;
42 
43  parent::__construct($iterator);
44  }
45 
51  public function accept()
52  {
53  $fileinfo = $this->current();
54 
55  foreach ($this->filters as $filter) {
56  if (false === call_user_func($filter, $fileinfo)) {
57  return false;
58  }
59  }
60 
61  return true;
62  }
63 }