Passed
Pull Request — master (#29)
by
unknown
02:56
created

ChainIterator::extend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
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\Interfaces\FiniteIterableInterface;
11
use Zicht\Itertools\lib\Traits\FiniteIterableTrait;
12
13
/**
14
 * Class ChainIterator
15
 *
16
 * @package Zicht\Itertools\lib
17
 */
18
class ChainIterator extends \AppendIterator implements FiniteIterableInterface
19
{
20
    use FiniteIterableTrait;
21
22
    /**
23
     * ChainIterator constructor.
24
     */
25 18
    public function __construct()
26
    {
27 18
        parent::__construct();
28 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...
29 14
            if (!$iterable instanceof \Iterator) {
30 3
                throw new \InvalidArgumentException(sprintf('Not all arguments are iterators'));
31
            }
32 11
            $this->append($iterable);
33
        }
34 15
    }
35
36
    /**
37
     * Extend this iterator with the contents of $iterable
38
     *
39
     * @param array|string|\Iterator $iterable
40
     */
41 3
    public function extend($iterable)
42
    {
43 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...
44 3
    }
45
}
46