1 | <?php namespace Limoncello\Validation\Rules; |
||
28 | abstract class BaseRule implements RuleInterface |
||
29 | { |
||
30 | /** |
||
31 | * State key. |
||
32 | */ |
||
33 | const STATE_ERROR_VALUE = 0; |
||
34 | |||
35 | /** |
||
36 | * State key. |
||
37 | */ |
||
38 | const STATE_LAST = self::STATE_ERROR_VALUE; |
||
39 | |||
40 | /** |
||
41 | * Property key. |
||
42 | */ |
||
43 | const PROPERTY_NAME = 0; |
||
44 | |||
45 | /** |
||
46 | * Property key. |
||
47 | */ |
||
48 | const PROPERTY_IS_CAPTURE_ENABLED = self::PROPERTY_NAME + 1; |
||
49 | |||
50 | /** |
||
51 | * Property key. |
||
52 | */ |
||
53 | const PROPERTY_LAST = self::PROPERTY_IS_CAPTURE_ENABLED; |
||
54 | |||
55 | /** |
||
56 | * @var string|null |
||
57 | */ |
||
58 | private $name = null; |
||
59 | |||
60 | /** |
||
61 | * @var bool |
||
62 | */ |
||
63 | private $isCaptureEnabled = false; |
||
64 | |||
65 | /** |
||
66 | * @var RuleInterface|null |
||
67 | */ |
||
68 | private $parent = null; |
||
69 | |||
70 | /** |
||
71 | * @inheritdoc |
||
72 | */ |
||
73 | 32 | public function getName(): string |
|
81 | |||
82 | /** |
||
83 | * @inheritdoc |
||
84 | */ |
||
85 | 27 | public function setName(string $name): RuleInterface |
|
91 | |||
92 | /** |
||
93 | * @inheritdoc |
||
94 | */ |
||
95 | 1 | public function unsetName(): RuleInterface |
|
101 | |||
102 | /** |
||
103 | * @inheritdoc |
||
104 | */ |
||
105 | 28 | public function enableCapture(): RuleInterface |
|
111 | |||
112 | /** |
||
113 | * @inheritdoc |
||
114 | */ |
||
115 | 1 | public function disableCapture(): RuleInterface |
|
121 | |||
122 | /** |
||
123 | * @inheritdoc |
||
124 | */ |
||
125 | 32 | public function isCaptureEnabled(): bool |
|
129 | |||
130 | /** |
||
131 | * @inheritdoc |
||
132 | */ |
||
133 | 17 | public function getParent(): ?RuleInterface |
|
137 | |||
138 | /** |
||
139 | * @inheritdoc |
||
140 | */ |
||
141 | 17 | public function setParent(RuleInterface $rule): RuleInterface |
|
147 | |||
148 | /** |
||
149 | * @inheritdoc |
||
150 | */ |
||
151 | 1 | public function unsetParent(): RuleInterface |
|
157 | |||
158 | /** |
||
159 | * @return array |
||
160 | */ |
||
161 | 31 | protected function getStandardProperties(): array |
|
165 | |||
166 | /** |
||
167 | * @param string $name |
||
168 | * @param bool $isCaptureEnabled |
||
169 | * |
||
170 | * @return array |
||
171 | */ |
||
172 | 31 | protected function composeStandardProperties(string $name, bool $isCaptureEnabled): array |
|
179 | |||
180 | /** |
||
181 | * @param mixed $result |
||
182 | * |
||
183 | * @return array |
||
184 | * |
||
185 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
186 | */ |
||
187 | 15 | protected static function createSuccessReply($result): array |
|
191 | |||
192 | /** |
||
193 | * @param ContextInterface $context |
||
194 | * @param mixed $errorValue |
||
195 | * @param int $errorCode |
||
196 | * @param mixed|null $errorContext |
||
197 | * |
||
198 | * @return array |
||
199 | * |
||
200 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
201 | */ |
||
202 | 12 | protected static function createErrorReply( |
|
210 | } |
||
211 |