Passed
Push — master ( cdd133...439166 )
by Martin
03:26
created

Collection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 100 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 24
loc 24
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 19 19 3

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
declare(strict_types = 1);
4
5
namespace KingsonDe\Marshal\Data;
6
7 View Code Duplication
class Collection extends AbstractDataStructure {
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...
8
9
    /**
10
     * @inheritdoc
11
     */
12 6
    public function build(): array {
13 6
        $mapper = $this->getMapper();
14 6
        $output = [];
15
16 6
        $data = $this->getData();
17
        /** @var \Traversable $modelCollection */
18 6
        $modelCollection = \array_shift($data);
19
20 6
        foreach ($modelCollection as $model) {
21 6
            $item = $mapper->map($model, ...$data);
0 ignored issues
show
Bug introduced by
The method map() does not exist on KingsonDe\Marshal\AbstractMapper. Since it exists in all sub-types, consider adding an abstract or default implementation to KingsonDe\Marshal\AbstractMapper. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
            /** @scrutinizer ignore-call */ 
22
            $item = $mapper->map($model, ...$data);
Loading history...
22
23 6
            if (!\is_array($item)) {
24 1
                continue;
25
            }
26
27 6
            $output[] = $item;
28
        }
29
30 6
        return $output;
31
    }
32
}
33