Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / phpunit / phpunit / src / Runner / Filter / Factory.php
1 <?php
2 /*
3  * This file is part of PHPUnit.
4  *
5  * (c) Sebastian Bergmann <sebastian@phpunit.de>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * @since Class available since Release 4.0.0
13  */
14 class PHPUnit_Runner_Filter_Factory
15 {
16     /**
17      * @var array
18      */
19     private $filters = array();
20
21     /**
22      * @param ReflectionClass $filter
23      * @param mixed           $args
24      */
25     public function addFilter(ReflectionClass $filter, $args)
26     {
27         if (!$filter->isSubclassOf('RecursiveFilterIterator')) {
28             throw new InvalidArgumentException(
29                 sprintf(
30                     'Class "%s" does not extend RecursiveFilterIterator',
31                     $filter->name
32                 )
33             );
34         }
35
36         $this->filters[] = array($filter, $args);
37     }
38
39     /**
40      * @return FilterIterator
41      */
42     public function factory(Iterator $iterator, PHPUnit_Framework_TestSuite $suite)
43     {
44         foreach ($this->filters as $filter) {
45             list($class, $args) = $filter;
46             $iterator           = $class->newInstance($iterator, $args, $suite);
47         }
48
49         return $iterator;
50     }
51 }