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

AbstractMapper::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
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 3
    protected function item(AbstractMapper $mapper, ...$data): Item {
19 3
        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 3
    protected function collection(AbstractMapper $mapper, ...$data): Collection {
27 3
        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