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

Collection::build()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 10

Duplication

Lines 19
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 3
nop 0
dl 19
loc 19
ccs 11
cts 11
cp 1
crap 3
rs 9.4285
c 0
b 0
f 0
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