ZonesAwareTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 21
loc 21
ccs 9
cts 9
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A setZones() 12 12 4

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
namespace FilmTools\ExposureSeries;
3
4 View Code Duplication
trait ZonesAwareTrait
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
5
{
6
    use ZonesProviderTrait;
7
8
9
    /**
10
     * @param  array|Traversable $zones
0 ignored issues
show
Bug introduced by
The type FilmTools\ExposureSeries\Traversable was not found. Did you mean Traversable? If so, make sure to prefix the type with \.
Loading history...
11
     * @return self
12
     */
13 28
    public function setZones($zones)
14
    {
15 28
        if ($zones instanceOf ZonesProviderInterface):
16 8
            $zones = $zones->getZones();
17 22
        elseif ($zones instanceOf \Traversable) :
18 4
            $zones = iterator_to_array($zones);
19 17
        elseif (!is_array($zones)):
20 12
            throw new \InvalidArgumentException("Traversable or array expected.", 1);
21
        endif;
22
23 16
        $this->zones = $zones;
0 ignored issues
show
Bug Best Practice introduced by
The property zones does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
24 16
        return $this;
25
    }
26
27
}
28