ActiveSalesmanFilterIterator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 33
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A accept() 0 12 2
1
<?php
2
namespace Germania\Salesmen;
3
4
class ActiveSalesmanFilterIterator extends \FilterIterator
5
{
6
7
    /**
8
     * @var boolean
9
     */
10
    public $active_flag = true;
11
12
    /**
13
     * @param \Traversable $collection      Collection of SalesmanIdProviderInterface
14
     * @param bool $active_flag
15
     */
16 32
    public function __construct( \Traversable $collection, $active_flag = true )
0 ignored issues
show
Unused Code introduced by
The parameter $active_flag is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
    {
18
        // Take care of Traversable's two faces,
19
        // since both IteratorAggregate and Iterator implement Traversable
20 32
        parent::__construct( $collection instanceOf \IteratorAggregate ? $collection->getIterator() : $collection );
21 32
    }
22
23 32
    public function accept()
24
    {
25 32
        $item = $this->getInnerIterator()->current();
26
27
        // Disclose items not implementing SalesmanIdProviderInterface
28 32
        if (!$item instanceOf SalesmanIdProviderInterface) {
29
            return false;
30
        }
31
32 32
        return $item->isActive() == $this->active_flag;
33
34
    }
35
36
}
37