Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
13 | final class IntegerNormalizerBuilder implements IIntegerNormalizerBuilder |
||
14 | { |
||
15 | private ?int $divisor = null; |
||
16 | private ?int $min = null; |
||
17 | |||
18 | public function build(): IIntegerNormalizer |
||
19 | { |
||
20 | $this->validate(); |
||
21 | |||
22 | return new IntegerNormalizer( |
||
23 | $this->divisor, |
||
|
|||
24 | $this->min, |
||
25 | ); |
||
26 | } |
||
27 | |||
28 | private function validate(): void |
||
29 | { |
||
30 | match (true) { |
||
31 | null === $this->divisor => throw new LogicException('Divisor value is not set.'), |
||
32 | $this->min === null => throw new LogicException('Min value is not set.'), |
||
33 | default => null, |
||
34 | }; |
||
35 | } |
||
36 | |||
37 | public function withDivisor(int $divisor): IIntegerNormalizerBuilder |
||
42 | } |
||
43 | |||
44 | public function withMin(int $min): IIntegerNormalizerBuilder |
||
49 | } |
||
50 | } |
||
51 |