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

CollectionCallable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 18 18 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 CollectionCallable extends AbstractCallableDataStructure {
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 4
    public function build() {
13 4
        $output = [];
14
15 4
        $data = $this->getData();
16
        /** @var \Traversable $modelCollection */
17 4
        $modelCollection = \array_shift($data);
18
19 4
        foreach ($modelCollection as $model) {
20 4
            $item = $this->getMappingFunction()($model, ...$data);
21
22 4
            if (!\is_array($item)) {
23 1
                continue;
24
            }
25
26 4
            $output[] = $item;
27
        }
28
29 4
        return $output;
30
    }
31
}
32