Total Complexity | 6 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | trait MaybeBelongsToField |
||
9 | { |
||
10 | private ?string $field = null; |
||
11 | |||
12 | public function getField(): ?string |
||
15 | } |
||
16 | |||
17 | /** |
||
18 | * @throws ValidationException |
||
19 | */ |
||
20 | public function field(?string $field): static |
||
21 | { |
||
22 | $instance = clone $this; |
||
23 | $instance->setField($field); |
||
24 | return $instance; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @throws ValidationException |
||
29 | */ |
||
30 | private function setField(?string $field): void |
||
34 | } |
||
35 | |||
36 | public function belongsToField(): bool |
||
37 | { |
||
38 | return $this->field !== null; |
||
39 | } |
||
40 | |||
41 | private function newEmptyValidationResult(): ValidationResult|ValidationResultByField |
||
47 | } |
||
48 | } |
||
49 |