AbstractMapper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A itemCallable() 0 2 1
A collection() 0 2 1
A item() 0 2 1
A collectionCallable() 0 2 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace KingsonDe\Marshal;
6
7
use KingsonDe\Marshal\Data\Collection;
8
use KingsonDe\Marshal\Data\CollectionCallable;
9
use KingsonDe\Marshal\Data\Item;
10
use KingsonDe\Marshal\Data\ItemCallable;
11
12
/**
13
 * Concrete Mapper classes MUST implement a "map" function that must return an array or null.
14
 * The reason of not having an abstract function for the "map" function is type hinting.
15
 */
16
abstract class AbstractMapper {
17
18 7
    protected function item(AbstractMapper $mapper, ...$data): Item {
19 7
        return new Item($mapper, ...$data);
20
    }
21
22 1
    protected function itemCallable(callable $mappingFunction, ...$data): ItemCallable {
23 1
        return new ItemCallable($mappingFunction, ...$data);
24
    }
25
26 7
    protected function collection(AbstractMapper $mapper, ...$data): Collection {
27 7
        return new Collection($mapper, ...$data);
28
    }
29
30 1
    protected function collectionCallable(callable $mappingFunction, ...$data): CollectionCallable {
31 1
        return new CollectionCallable($mappingFunction, ...$data);
32
    }
33
}
34