1 | <?php namespace Limoncello\Application\FormValidation\Execution; |
||
26 | class FormRuleSerializer |
||
27 | { |
||
28 | /** Serialized indexes key */ |
||
29 | protected const SERIALIZED_RULE_SETS = 0; |
||
30 | |||
31 | /** Serialized rules key */ |
||
32 | protected const SERIALIZED_BLOCKS = self::SERIALIZED_RULE_SETS + 1; |
||
33 | |||
34 | // Rules array serialization keys |
||
35 | |||
36 | /** Index key */ |
||
37 | protected const RULES_ARRAY_INDEXES = 0; |
||
38 | |||
39 | /** Index key */ |
||
40 | protected const RULES_ARRAY_START_INDEXES = self::RULES_ARRAY_INDEXES + 1; |
||
41 | |||
42 | /** Index key */ |
||
43 | protected const RULES_ARRAY_END_INDEXES = self::RULES_ARRAY_START_INDEXES + 1; |
||
44 | |||
45 | /** |
||
46 | * @var BlockSerializerInterface |
||
47 | */ |
||
48 | private $blockSerializer; |
||
49 | |||
50 | /** |
||
51 | * @var array |
||
52 | */ |
||
53 | private $ruleSets; |
||
54 | |||
55 | /** |
||
56 | * Constructor. |
||
57 | */ |
||
58 | 3 | public function __construct() |
|
63 | |||
64 | /** |
||
65 | * @param string $name |
||
66 | * @param RuleInterface[] $attributeRules |
||
67 | * |
||
68 | * @return self |
||
69 | */ |
||
70 | 3 | public function addResourceRules(string $name, array $attributeRules): self |
|
81 | |||
82 | /** |
||
83 | * @return array |
||
84 | * |
||
85 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
86 | */ |
||
87 | 3 | public function getData(): array |
|
94 | |||
95 | /** |
||
96 | * @param string $name |
||
97 | * @param array $data |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | 2 | public static function getAttributeRules(string $name, array $data): array |
|
109 | |||
110 | /** |
||
111 | * @param array $data |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | 2 | public static function extractBlocks(array $data): array |
|
123 | |||
124 | /** |
||
125 | * @param array $serializedRules |
||
126 | * |
||
127 | * @return array |
||
128 | */ |
||
129 | 2 | public static function getRulesIndexes(array $serializedRules): array |
|
137 | |||
138 | /** |
||
139 | * @param array $serializedRules |
||
140 | * |
||
141 | * @return array |
||
142 | */ |
||
143 | 2 | public static function getRulesStartIndexes(array $serializedRules): array |
|
151 | |||
152 | /** |
||
153 | * @param array $serializedRules |
||
154 | * |
||
155 | * @return array |
||
156 | */ |
||
157 | 2 | public static function getRulesEndIndexes(array $serializedRules): array |
|
165 | |||
166 | /** |
||
167 | * @param int $index |
||
168 | * @param array $blocks |
||
169 | * |
||
170 | * @return bool |
||
171 | */ |
||
172 | 2 | public static function isRuleExist(int $index, array $blocks): bool |
|
178 | |||
179 | /** |
||
180 | * @param array $serializedRules |
||
181 | * |
||
182 | * @return array |
||
183 | * |
||
184 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
185 | */ |
||
186 | 3 | protected static function getBlocks(array $serializedRules): array |
|
192 | |||
193 | /** |
||
194 | * @return BlockSerializerInterface |
||
195 | */ |
||
196 | 3 | protected function getSerializer(): BlockSerializerInterface |
|
200 | |||
201 | /** |
||
202 | * @return BlockSerializerInterface |
||
203 | */ |
||
204 | 3 | protected function createBlockSerializer(): BlockSerializerInterface |
|
208 | |||
209 | /** |
||
210 | * @param RuleInterface[] $rules |
||
211 | * |
||
212 | * @return array |
||
213 | */ |
||
214 | 3 | private function serializeRulesArray(array $rules): array |
|
233 | } |
||
234 |