1 | <?php |
||
10 | class TypeCast |
||
11 | { |
||
12 | /** @var string */ |
||
13 | protected $paramDelimiter = ':'; |
||
14 | /** @var string */ |
||
15 | protected $keysDelimiter = '.'; |
||
16 | |||
17 | /** @var array */ |
||
18 | protected $types = []; |
||
19 | |||
20 | /** @var DeepArray */ |
||
21 | protected $deepArrayService; |
||
22 | /** @var RegExpFactory */ |
||
23 | protected $regExpFactory; |
||
24 | /** @var PropException */ |
||
25 | protected $notExistValue; |
||
26 | |||
27 | 27 | public function __construct(DeepArray $deepArrayService, RegExpFactory $regExpFactory) |
|
45 | |||
46 | 1 | public function getRegExpFactory(): RegExpFactory |
|
50 | |||
51 | 3 | protected function datetimeFormat(\DateTime $value, string $format = 'd-m-Y'): string |
|
55 | |||
56 | /** |
||
57 | * @param array $coll |
||
58 | * @param array $rules |
||
59 | * @return array |
||
60 | * @throws PropException |
||
61 | */ |
||
62 | 1 | protected function eachHandlerType(array $coll, array $rules): array |
|
70 | |||
71 | /** |
||
72 | * @param string $type |
||
73 | * @return callable |
||
74 | */ |
||
75 | protected function setType(string $type): callable |
||
83 | |||
84 | /** |
||
85 | * @param string $name |
||
86 | * @param callable $handler |
||
87 | * @return $this |
||
88 | */ |
||
89 | 27 | public function registerType(string $name, callable $handler): self |
|
94 | |||
95 | 2 | public function getTypes(): array |
|
99 | |||
100 | /** |
||
101 | * @param array $data |
||
102 | * @param array $rules |
||
103 | * |
||
104 | * @return array |
||
105 | * @throws PropException |
||
106 | */ |
||
107 | 24 | public function cast(array $data, array $rules): array |
|
120 | |||
121 | /** |
||
122 | * @param mixed $value |
||
123 | * @param array $rules |
||
124 | * @return mixed |
||
125 | * @throws PropException |
||
126 | */ |
||
127 | 23 | protected function castValue($value, array $rules) |
|
139 | |||
140 | /** |
||
141 | * @param mixed $value |
||
142 | * @param array $params |
||
143 | * @param string $handlerAlias |
||
144 | * @return mixed |
||
145 | * @throws PropException |
||
146 | */ |
||
147 | 23 | protected function applyCastType($value, array $params, string $handlerAlias) |
|
157 | |||
158 | /** |
||
159 | * @param string $name |
||
160 | * @param array $data |
||
161 | * @param mixed $default |
||
162 | * @return mixed |
||
163 | */ |
||
164 | 24 | protected function getValue(string $name, array $data, $default) |
|
169 | |||
170 | 20 | protected function setValue(string $name, array &$data, $value) |
|
175 | |||
176 | 4 | public function extractArrayRule(array $rule): array |
|
180 | |||
181 | 23 | public function extractStringRule(string $rule): array |
|
188 | } |
||
189 |