1 | <?php |
||
8 | class DelegatedValidator |
||
9 | { |
||
10 | use AccessProtectedTrait; |
||
11 | /** |
||
12 | * The Validator resolved instance. |
||
13 | * |
||
14 | * @var \Illuminate\Validation\Validator |
||
15 | */ |
||
16 | protected $validator; |
||
17 | |||
18 | /** |
||
19 | * Closure to invoke non accessible Validator methods. |
||
20 | * |
||
21 | * @var Closure |
||
22 | */ |
||
23 | protected $validatorMethod; |
||
24 | |||
25 | /** |
||
26 | * DelegatedValidator constructor. |
||
27 | * |
||
28 | * @param \Illuminate\Validation\Validator $validator |
||
29 | */ |
||
30 | 20 | public function __construct(BaseValidator $validator) |
|
35 | |||
36 | /** |
||
37 | * Call validator method. |
||
38 | * |
||
39 | * @param string $method |
||
40 | * @param array $args |
||
41 | * @return mixed |
||
42 | */ |
||
43 | 6 | private function callValidator($method, $args = []) |
|
47 | |||
48 | /** |
||
49 | * Get current \Illuminate\Validation\Validator instance. |
||
50 | * |
||
51 | * @return \Illuminate\Validation\Validator |
||
52 | */ |
||
53 | 1 | public function getValidator() |
|
57 | |||
58 | /** |
||
59 | * Get the data under validation. |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | 1 | public function getData() |
|
67 | |||
68 | /** |
||
69 | * Set the data under validation. |
||
70 | * |
||
71 | * @param array |
||
72 | */ |
||
73 | 1 | public function setData($data) |
|
77 | |||
78 | /** |
||
79 | * Get the validation rules. |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | 1 | public function getRules() |
|
87 | |||
88 | /** |
||
89 | * Get the files under validation. |
||
90 | * |
||
91 | * @return array |
||
92 | */ |
||
93 | 2 | public function getFiles() |
|
101 | |||
102 | /** |
||
103 | * Set the files under validation. |
||
104 | * |
||
105 | * @param array $files |
||
106 | * |
||
107 | * @return BaseValidator |
||
108 | */ |
||
109 | 2 | public function setFiles(array $files) |
|
117 | |||
118 | /** |
||
119 | * Determine if a given rule implies the attribute is required. |
||
120 | * |
||
121 | * @param string $rule |
||
122 | * |
||
123 | * @return bool |
||
124 | */ |
||
125 | 1 | public function isImplicit($rule) |
|
129 | |||
130 | /** |
||
131 | * Replace all error message place-holders with actual values. |
||
132 | * |
||
133 | * @param string $message |
||
134 | * @param string $attribute |
||
135 | * @param string $rule |
||
136 | * @param array $parameters |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | 1 | public function doReplacements($message, $attribute, $rule, $parameters) |
|
144 | |||
145 | /** |
||
146 | * Determine if the given attribute has a rule in the given set. |
||
147 | * |
||
148 | * @param string $attribute |
||
149 | * @param string|array $rules |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | 1 | public function hasRule($attribute, $rules) |
|
157 | |||
158 | /** |
||
159 | * Get the validation message for an attribute and rule. |
||
160 | * |
||
161 | * @param string $attribute |
||
162 | * @param string $rule |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | 1 | public function getMessage($attribute, $rule) |
|
170 | |||
171 | /** |
||
172 | * Extract the rule name and parameters from a rule. |
||
173 | * |
||
174 | * @param array|string $rules |
||
175 | * |
||
176 | * @return array |
||
177 | */ |
||
178 | 1 | public function parseRule($rules) |
|
182 | |||
183 | /** |
||
184 | * Explode the rules into an array of rules. |
||
185 | * |
||
186 | * @param string|array $rules |
||
187 | * @return array |
||
188 | */ |
||
189 | 1 | public function explodeRules($rules) |
|
193 | |||
194 | /** |
||
195 | * Add conditions to a given field based on a Closure. |
||
196 | * |
||
197 | * @param string $attribute |
||
198 | * @param string|array $rules |
||
199 | * @param callable $callback |
||
200 | * @return void |
||
201 | */ |
||
202 | 1 | public function sometimes($attribute, $rules, callable $callback) |
|
206 | |||
207 | /** |
||
208 | * Delegate method calls to validator instance. |
||
209 | * |
||
210 | * @param $method |
||
211 | * @param $params |
||
212 | * |
||
213 | * @return mixed |
||
214 | */ |
||
215 | 1 | public function __call($method, $params) |
|
221 | } |
||
222 |