ChainIterator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 24 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 6
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 10 3
A extend() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @copyright Zicht Online <http://zicht.nl>
4
 */
5
6
namespace Zicht\Itertools\lib;
7
8
use Zicht\Itertools\conversions;
9
use Zicht\Itertools\lib\Interfaces\FiniteIterableInterface;
10
use Zicht\Itertools\lib\Traits\FiniteIterableTrait;
11
12
class ChainIterator extends \AppendIterator implements FiniteIterableInterface
13
{
14
    use FiniteIterableTrait;
15
16 18
    public function __construct()
17
    {
18 18
        parent::__construct();
19 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...
20 14
            if (!$iterable instanceof \Iterator) {
21 3
                throw new \InvalidArgumentException(sprintf('Not all arguments are iterators'));
22
            }
23 11
            $this->append($iterable);
24
        }
25 15
    }
26
27
    /**
28
     * Extend this iterator with the contents of $iterable
29
     *
30
     * @param array|string|\Iterator $iterable
31
     */
32 3
    public function extend($iterable)
33
    {
34 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...
Deprecated Code introduced by
The function Zicht\Itertools\conversions\mixed_to_iterator() has been deprecated with message: Use \Zicht\Itertools\util\Conversions::mixedToIterator, will be removed in version 3.0

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
35 3
    }
36
}
37