Total Complexity | 8 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | final class ValidationContext |
||
8 | { |
||
9 | private ?DataSetInterface $dataSet; |
||
10 | private ?string $attribute = null; |
||
11 | private bool $previousRulesErrored = false; |
||
12 | private array $params = []; |
||
13 | |||
14 | 15 | public function __construct( |
|
15 | ?DataSetInterface $dataSet = null, |
||
16 | ?string $attribute = null |
||
17 | ) { |
||
18 | 15 | $this->dataSet = $dataSet; |
|
19 | 15 | $this->attribute = $attribute; |
|
20 | 15 | } |
|
21 | |||
22 | /** |
||
23 | * @return DataSetInterface|null Optional data set. |
||
24 | */ |
||
25 | 1 | public function getDataSet(): ?DataSetInterface |
|
26 | { |
||
27 | 1 | return $this->dataSet; |
|
28 | } |
||
29 | |||
30 | 1 | public function getAttribute(): ?string |
|
31 | { |
||
32 | 1 | return $this->attribute; |
|
33 | } |
||
34 | |||
35 | 2 | public function withAttribute(?string $attribute): self |
|
36 | { |
||
37 | 2 | $new = clone $this; |
|
38 | 2 | $new->attribute = $attribute; |
|
39 | 2 | return $new; |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * @return bool set to true if rule is part of a group of rules and one of the previous validations failed |
||
44 | */ |
||
45 | 11 | public function isPreviousRulesErrored(): bool |
|
46 | { |
||
47 | 11 | return $this->previousRulesErrored; |
|
48 | } |
||
49 | |||
50 | 12 | public function withPreviousRulesErrored(bool $previousRulesErrored): self |
|
51 | { |
||
52 | 12 | $new = clone $this; |
|
53 | 12 | $new->previousRulesErrored = $previousRulesErrored; |
|
54 | 12 | return $new; |
|
55 | } |
||
56 | |||
57 | 1 | public function getParams(): array |
|
60 | } |
||
61 | |||
62 | 2 | public function withParams(array $params): self |
|
63 | { |
||
67 | } |
||
68 | } |
||
69 |