Passed
Pull Request — master (#1)
by Martin
01:58
created

AbstractObjectMapper::item()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
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