Passed
Pull Request — master (#19)
by
unknown
02:33
created

ChainIterator::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 6
Ratio 60 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 6
loc 10
ccs 7
cts 7
cp 1
crap 3
rs 9.4285
c 1
b 0
f 0
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 View Code Duplication
        foreach (func_get_args() as $iterable) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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