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

CollectionCallable::build()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 9

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 3
nop 0
dl 18
loc 18
ccs 10
cts 10
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 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