Passed
Push — master ( 2f6942...d6d802 )
by Chris
28:11
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 174
    public function withItems(array $items): self
24
    {
25 174
        $this->items = $items;
26
27 174
        return $this;
28
    }
29
30 174
    public function withGenerator(Closure $generator): self
31
    {
32 174
        $this->generator = $generator;
33
34 174
        return $this;
35
    }
36
37 24
    public function withAccessors(array $accessors): self
38
    {
39 24
        $this->accessors = $accessors;
40
41 24
        return $this;
42
    }
43
44 171
    public function withIdentifier(?string $identifier): self
45
    {
46 171
        $this->identifier = $identifier;
47
48 171
        return $this;
49
    }
50
51 24
    public function thatIsMapped(): self
52
    {
53 24
        $this->isMap = true;
54
55 24
        return $this;
56
    }
57
58 150
    public function thatIsNotMapped(): self
59
    {
60 150
        $this->isMap = false;
61
62 150
        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 174
    public function build(): CollectionKernel
80
    {
81 174
        return new CollectionKernel(
82 174
            $this->items,
83 174
            $this->generator,
84 174
            $this->identifier,
85 174
            $this->accessors,
86 174
            $this->isMap,
87 174
            $this->jsonSerializer,
88
        );
89
    }
90
}
91