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

AbstractObjectMapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A item() 0 2 1
A collection() 0 8 2
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