Completed
Pull Request — master (#1)
by Martin
02:24
created

AbstractObjectMapper::collection()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace KingsonDe\Marshal;
5
6
use KingsonDe\Marshal\Data\FlexibleData;
7
8
abstract class AbstractObjectMapper {
9
10
    /**
11
     * @param FlexibleData $flexibleData
12
     * @return mixed
13
     */
14
    abstract public function map(FlexibleData $flexibleData);
15
16
    /**
17
     * @param AbstractObjectMapper $mapper
18
     * @param FlexibleData $flexibleData
19
     * @return mixed
20
     */
21 1
    public function item(AbstractObjectMapper $mapper, FlexibleData $flexibleData) {
22 1
        return $mapper->map($flexibleData);
23
    }
24
25 1
    public function collection(AbstractObjectMapper $mapper, FlexibleData $flexibleData): array {
26 1
        $data = [];
27
28 1
        foreach ($flexibleData as $item) {
29 1
            $data[] = $mapper->map($item);
30
        }
31
32 1
        return $data;
33
    }
34
}
35