Passed
Push — master ( a4571b...162929 )
by Chris
07:18
created

CollectionKernelBuilder::thatIsMapped()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace WebTheory\Collection\Kernel\Builder;
4
5
use Closure;
6
use WebTheory\Collection\Contracts\JsonSerializerInterface;
7
use WebTheory\Collection\Kernel\CollectionKernel;
8
9
class CollectionKernelBuilder
10
{
11
    protected array $items = [];
12
13
    protected Closure $generator;
14
15
    protected array $accessors = [];
16
17
    protected ?string $identifier = null;
18
19
    protected bool $isMap = false;
20
21
    protected ?JsonSerializerInterface $jsonSerializer = null;
22
23 168
    public function withItems(array $items): self
24
    {
25 168
        $this->items = $items;
26
27 168
        return $this;
28
    }
29
30 168
    public function withGenerator(Closure $generator): self
31
    {
32 168
        $this->generator = $generator;
33
34 168
        return $this;
35
    }
36
37
    public function withAccessors(array $accessors): self
38
    {
39
        $this->accessors = $accessors;
40
41
        return $this;
42
    }
43
44 168
    public function withIdentifier(?string $identifier): self
45
    {
46 168
        $this->identifier = $identifier;
47
48 168
        return $this;
49
    }
50
51 24
    public function thatIsMapped(): self
52
    {
53 24
        $this->isMap = true;
54
55 24
        return $this;
56
    }
57
58 144
    public function thatIsNotMapped(): self
59
    {
60 144
        $this->isMap = false;
61
62 144
        return $this;
63
    }
64
65 120
    public function withMapped(bool $isMap): self
66
    {
67 120
        $this->isMap = $isMap;
68
69 120
        return $this;
70
    }
71
72
    public function withJsonSerializer(JsonSerializerInterface $jsonSerializer): self
73
    {
74
        $this->jsonSerializer = $jsonSerializer;
75
76
        return $this;
77
    }
78
79 168
    public function build(): CollectionKernel
80
    {
81 168
        return new CollectionKernel(
82 168
            $this->items,
83 168
            $this->generator,
84 168
            $this->identifier,
85 168
            $this->accessors,
86 168
            $this->isMap,
87 168
            $this->jsonSerializer,
88
        );
89
    }
90
}
91