Passed
Pull Request — master (#19)
by
unknown
03:59
created

ChainIterator   C

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 23

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 52
ccs 10
cts 10
cp 1
rs 5.5
wmc 4
lcom 0
cbo 23

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A extend() 0 4 1
1
<?php
2
/**
3
 * @author Boudewijn Schoon <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
7
namespace Zicht\Itertools\lib;
8
9
use Zicht\Itertools\conversions;
10
use Zicht\Itertools\lib\Traits\AllTrait;
11
use Zicht\Itertools\lib\Traits\AnyTrait;
12
use Zicht\Itertools\lib\Traits\ArrayAccessTrait;
13
use Zicht\Itertools\lib\Traits\ChainTrait;
14
use Zicht\Itertools\lib\Traits\CountableTrait;
15
use Zicht\Itertools\lib\Traits\CycleTrait;
16
use Zicht\Itertools\lib\Traits\DebugInfoTrait;
17
use Zicht\Itertools\lib\Traits\FilterTrait;
18
use Zicht\Itertools\lib\Traits\FirstTrait;
19
use Zicht\Itertools\lib\Traits\GroupByTrait;
20
use Zicht\Itertools\lib\Traits\ItemsTrait;
21
use Zicht\Itertools\lib\Traits\KeysTrait;
22
use Zicht\Itertools\lib\Traits\LastTrait;
23
use Zicht\Itertools\lib\Traits\MapByTrait;
24
use Zicht\Itertools\lib\Traits\MapTrait;
25
use Zicht\Itertools\lib\Traits\ReduceTrait;
26
use Zicht\Itertools\lib\Traits\ReversedTrait;
27
use Zicht\Itertools\lib\Traits\SliceTrait;
28
use Zicht\Itertools\lib\Traits\SortedTrait;
29
use Zicht\Itertools\lib\Traits\ToArrayTrait;
30
use Zicht\Itertools\lib\Traits\UniqueTrait;
31
use Zicht\Itertools\lib\Traits\ValuesTrait;
32
use Zicht\Itertools\lib\Traits\ZipTrait;
33
34
/**
35
 * Class ChainIterator
36
 *
37
 * @package Zicht\Itertools\lib
38
 */
39
class ChainIterator extends \AppendIterator implements \Countable, \ArrayAccess
40
{
41
    use ArrayAccessTrait;
42
    use CountableTrait;
43
    use DebugInfoTrait;
44
45
    // Fluent interface traits
46
    use AllTrait;
47
    use AnyTrait;
48
    use ChainTrait;
49
    use CycleTrait;
50
    use FilterTrait;
51
    use FirstTrait;
52
    use GroupByTrait;
53
    use ItemsTrait;
54
    use KeysTrait;
55
    use LastTrait;
56
    use MapByTrait;
57
    use MapTrait;
58
    use ReduceTrait;
59
    use ReversedTrait;
60
    use SliceTrait;
61
    use SortedTrait;
62
    use ToArrayTrait;
63
    use UniqueTrait;
64
    use ValuesTrait;
65
    use ZipTrait;
66
67
    /**
68
     * ChainIterator constructor.
69
     */
70 18
    public function __construct(/* \Iterator $iterable, \Iterator $iterable2, ... */)
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
71
    {
72 18
        parent::__construct();
73 18
        foreach (func_get_args() as $iterable) {
74 13
            if (!$iterable instanceof \Iterator) {
75 3
                throw new \InvalidArgumentException(sprintf('Not all arguments are iterators'));
76
            }
77 10
            $this->append($iterable);
78
        }
79 15
    }
80
81
    /**
82
     * Extend this iterator with the contents of $iterable
83
     *
84
     * @param array|string|\Iterator $iterable
85
     */
86 3
    public function extend($iterable)
87
    {
88 3
        parent::append(conversions\mixed_to_iterator($iterable));
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (append() instead of extend()). Are you sure this is correct? If so, you might want to change this to $this->append().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
89 3
    }
90
}
91