Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
75.00% |
3 / 4 |
CRAP | |
92.86% |
13 / 14 |
| GekRecursiveIteratorIterator | |
0.00% |
0 / 1 |
|
75.00% |
3 / 4 |
10.04 | |
92.86% |
13 / 14 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| next | |
100.00% |
1 / 1 |
5 | |
100.00% |
9 / 9 |
|||
| getDephtFilterFn | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
|||
| setDephtFilterFn | |
100.00% |
1 / 1 |
2 | |
100.00% |
2 / 2 |
|||
| <?php | |
| namespace Gek\FileFinder\Iterators; | |
| use RecursiveIteratorIterator; | |
| use Traversable; | |
| class GekRecursiveIteratorIterator extends \RecursiveIteratorIterator | |
| { | |
| /** | |
| * @var callable|null | |
| */ | |
| protected $dephtFilterFn = null; | |
| /** | |
| * GekRecursiveIteratorIterator constructor. | |
| * @param Traversable $iterator | |
| * @param int $mode | |
| * @param int $flags | |
| */ | |
| public function __construct(Traversable $iterator, $mode = self::LEAVES_ONLY, $flags = 0) | |
| { | |
| parent::__construct($iterator, $mode, $flags); | |
| } | |
| public function next() | |
| { | |
| parent::next(); | |
| $fn = $this->dephtFilterFn; | |
| if($fn !== null){ | |
| $found = false; | |
| while ((! $found) && $this->valid()){ | |
| $found = $fn($this->getDepth()); | |
| if(! $found){ | |
| parent::next(); | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * @return callable|null | |
| */ | |
| public function getDephtFilterFn(): ?callable | |
| { | |
| return $this->dephtFilterFn; | |
| } | |
| /** | |
| * @param callable|null $dephtFilterFn | |
| */ | |
| public function setDephtFilterFn(?callable $dephtFilterFn): void | |
| { | |
| $this->dephtFilterFn = $dephtFilterFn; | |
| } | |
| } |