Passed
Push — master ( e79858...61a477 )
by Chris
07:44
created

CollectionKernelBuilder   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 29
c 1
b 0
f 0
dl 0
loc 77
ccs 0
cts 29
cp 0
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A withIdentifier() 0 5 1
A withMapped() 0 5 1
A withAccessors() 0 5 1
A withItems() 0 5 1
A withFactory() 0 5 1
A withPropertyResolver() 0 5 1
A withJsonSerializer() 0 5 1
A build() 0 9 1
1
<?php
2
3
namespace WebTheory\Collection\Kernel;
4
5
use WebTheory\Collection\Contracts\JsonSerializerInterface;
6
use WebTheory\Collection\Resolution\PropertyResolver;
7
8
class CollectionKernelBuilder
9
{
10
    protected array $items = [];
11
12
    /**
13
     * @var callable
14
     */
15
    protected $factory;
16
17
    protected ?string $identifier = null;
18
19
    protected bool $map = false;
20
21
    protected JsonSerializerInterface $jsonSerializer;
22
23
    protected PropertyResolver $propertyResolver;
24
25
    protected array $accessors = [];
26
27
    public function withItems(array $items): self
28
    {
29
        $this->items = $items;
30
31
        return $this;
32
    }
33
34
    public function withFactory(callable $factory): self
35
    {
36
        $this->factory = $factory;
37
38
        return $this;
39
    }
40
41
    public function withAccessors(array $accessors): self
42
    {
43
        $this->accessors = $accessors;
44
45
        return $this;
46
    }
47
48
    public function withIdentifier(string $identifier): self
49
    {
50
        $this->identifier = $identifier;
51
52
        return $this;
53
    }
54
55
    public function withMapped(bool $map): self
56
    {
57
        $this->map = $map;
58
59
        return $this;
60
    }
61
62
    public function withJsonSerializer(JsonSerializerInterface $jsonSerializer): self
63
    {
64
        $this->jsonSerializer = $jsonSerializer;
65
66
        return $this;
67
    }
68
69
    public function withPropertyResolver(PropertyResolver $propertyResolver): self
70
    {
71
        $this->propertyResolver = $propertyResolver;
72
73
        return $this;
74
    }
75
76
    public function build(): CollectionKernel
77
    {
78
        return new CollectionKernel(
79
            $this->items,
80
            $this->factory,
81
            $this->identifier,
82
            $this->accessors,
83
            $this->map,
84
            $this->jsonSerializer,
85
        );
86
    }
87
}
88