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 | 22 | 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 | * Determine if a given rule implies the attribute is required. |
||
90 | * |
||
91 | * @param string $rule |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | 1 | public function isImplicit($rule) |
|
99 | |||
100 | /** |
||
101 | * Replace all error message place-holders with actual values. |
||
102 | * |
||
103 | * @param string $message |
||
104 | * @param string $attribute |
||
105 | * @param string $rule |
||
106 | * @param array $parameters |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | 1 | public function doReplacements($message, $attribute, $rule, $parameters) |
|
114 | |||
115 | /** |
||
116 | * Determine if the given attribute has a rule in the given set. |
||
117 | * |
||
118 | * @param string $attribute |
||
119 | * @param string|array $rules |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | 1 | public function hasRule($attribute, $rules) |
|
127 | |||
128 | /** |
||
129 | * Get the validation message for an attribute and rule. |
||
130 | * |
||
131 | * @param string $attribute |
||
132 | * @param string $rule |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | 1 | public function getMessage($attribute, $rule) |
|
140 | |||
141 | /** |
||
142 | * Extract the rule name and parameters from a rule. |
||
143 | * |
||
144 | * @param array|string $rules |
||
145 | * |
||
146 | * @return array |
||
147 | */ |
||
148 | 1 | public function parseRule($rules) |
|
152 | |||
153 | /** |
||
154 | * Explode the rules into an array of rules. |
||
155 | * |
||
156 | * @param string|array $rules |
||
157 | * @return array |
||
158 | */ |
||
159 | 1 | public function explodeRules($rules) |
|
163 | |||
164 | /** |
||
165 | * Add conditions to a given field based on a Closure. |
||
166 | * |
||
167 | * @param string $attribute |
||
168 | * @param string|array $rules |
||
169 | * @param callable $callback |
||
170 | * @return void |
||
171 | */ |
||
172 | 1 | public function sometimes($attribute, $rules, callable $callback) |
|
176 | |||
177 | /** |
||
178 | * Delegate method calls to validator instance. |
||
179 | * |
||
180 | * @param $method |
||
181 | * @param $params |
||
182 | * |
||
183 | * @return mixed |
||
184 | */ |
||
185 | 5 | public function __call($method, $params) |
|
191 | } |
||
192 |