NotFilter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getIterator() 0 9 3
1
<?php
2
/**
3
 * This program is free software. It comes without any warranty, to
4
 * the extent permitted by applicable law. You can redistribute it
5
 * and/or modify it under the terms of the Do What The Fuck You Want
6
 * To Public License, Version 2, as published by Sam Hocevar. See
7
 * http://www.wtfpl.net/ for more details.
8
 */
9
10
declare(strict_types = 1);
11
12
namespace hanneskod\classtools\Iterator\Filter;
13
14
use hanneskod\classtools\Iterator\ClassIterator;
15
use hanneskod\classtools\Iterator\Filter;
16
17
/**
18
 * Negate a filter
19
 *
20
 * @author Hannes Forsgård <[email protected]>
21
 */
22
final class NotFilter extends ClassIterator implements Filter
23
{
24
    use FilterTrait;
25
26
    /**
27
     * @var Filter
28
     */
29
    private $filter;
30
31
    public function __construct(Filter $filter)
32
    {
33
        parent::__construct();
34
        $this->filter = $filter;
35
    }
36
37
    public function getIterator(): iterable
38
    {
39
        $filtered = iterator_to_array($this->filter->getIterator());
40
        foreach ($this->getBoundIterator() as $className => $reflectedClass) {
41
            if (!isset($filtered[$className])) {
42
                yield $className => $reflectedClass;
43
            }
44
        }
45
    }
46
}
47