Total Complexity | 86 |
Total Lines | 1120 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like IsoCodesValidator often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use IsoCodesValidator, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
10 | class IsoCodesValidator extends BaseValidator |
||
11 | { |
||
12 | /** |
||
13 | * Validate a BBAN code |
||
14 | * |
||
15 | * @param $attribute |
||
16 | * @param $value |
||
17 | * @param $parameters |
||
18 | * @return mixed |
||
19 | */ |
||
20 | public function validateBban($attribute, $value, $parameters) |
||
21 | { |
||
22 | return $this->runIsoCodesValidator(\IsoCodes\Bban::class, $value); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Validate a BSN (Dutch citizen service number) |
||
27 | * |
||
28 | * @param $attribute |
||
29 | * @param $value |
||
30 | * @param $parameters |
||
31 | * @return mixed |
||
32 | */ |
||
33 | public function validateBsn($attribute, $value, $parameters) |
||
34 | { |
||
35 | return $this->runIsoCodesValidator(\IsoCodes\Bsn::class, $value); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Validate a CIF code |
||
40 | * |
||
41 | * @param $attribute |
||
42 | * @param $value |
||
43 | * @param $parameters |
||
44 | * @return mixed |
||
45 | */ |
||
46 | public function validateCif($attribute, $value, $parameters) |
||
47 | { |
||
48 | return $this->runIsoCodesValidator(\IsoCodes\Cif::class, $value); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Validate a credit card number |
||
53 | * |
||
54 | * @param $attribute |
||
55 | * @param $value |
||
56 | * @param $parameters |
||
57 | * @return mixed |
||
58 | */ |
||
59 | public function validateCreditcard($attribute, $value, $parameters) |
||
60 | { |
||
61 | return $this->runIsoCodesValidator(\IsoCodes\CreditCard::class, $value); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Validate a EAN-8 code |
||
66 | * |
||
67 | * @param $attribute |
||
68 | * @param $value |
||
69 | * @param $parameters |
||
70 | * @return mixed |
||
71 | */ |
||
72 | public function validateEan8($attribute, $value, $parameters) |
||
73 | { |
||
74 | return $this->runIsoCodesValidator(\IsoCodes\Ean8::class, $value); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Validate a EAN-13 code |
||
79 | * |
||
80 | * @param $attribute |
||
81 | * @param $value |
||
82 | * @param $parameters |
||
83 | * @return mixed |
||
84 | */ |
||
85 | public function validateEan13($attribute, $value, $parameters) |
||
86 | { |
||
87 | return $this->runIsoCodesValidator(\IsoCodes\Ean13::class, $value); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * Validate a Global Document Type Identifier (GDTI) |
||
92 | * |
||
93 | * @param $attribute |
||
94 | * @param $value |
||
95 | * @param $parameters |
||
96 | * @return mixed |
||
97 | */ |
||
98 | public function validateGdti($attribute, $value, $parameters) |
||
99 | { |
||
100 | return $this->runIsoCodesValidator(\IsoCodes\Gdti::class, $value); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * Validate a Global Location Number (GLN) |
||
105 | * |
||
106 | * @param $attribute |
||
107 | * @param $value |
||
108 | * @param $parameters |
||
109 | * @return mixed |
||
110 | */ |
||
111 | public function validateGln($attribute, $value, $parameters) |
||
112 | { |
||
113 | return $this->runIsoCodesValidator(\IsoCodes\Gln::class, $value); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Validate a Global Returnable Asset Identifier |
||
118 | * |
||
119 | * @param $attribute |
||
120 | * @param $value |
||
121 | * @param $parameters |
||
122 | * @return mixed |
||
123 | */ |
||
124 | public function validateGrai($attribute, $value, $parameters) |
||
125 | { |
||
126 | return $this->runIsoCodesValidator(\IsoCodes\Grai::class, $value); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * Validate a Global Service Relation Number (GS1) |
||
131 | * |
||
132 | * @param $attribute |
||
133 | * @param $value |
||
134 | * @param $parameters |
||
135 | * @return mixed |
||
136 | */ |
||
137 | public function validateGsrn($attribute, $value, $parameters) |
||
138 | { |
||
139 | return $this->runIsoCodesValidator(\IsoCodes\Gsrn::class, $value); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Validate a GTIN-8 code |
||
144 | * |
||
145 | * @param $attribute |
||
146 | * @param $value |
||
147 | * @param $parameters |
||
148 | * @return mixed |
||
149 | */ |
||
150 | public function validateGtin8($attribute, $value, $parameters) |
||
151 | { |
||
152 | return $this->runIsoCodesValidator(\IsoCodes\Gtin8::class, $value); |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * Validate a GTIN-12 code |
||
157 | * |
||
158 | * @param $attribute |
||
159 | * @param $value |
||
160 | * @param $parameters |
||
161 | * @return mixed |
||
162 | */ |
||
163 | public function validateGtin12($attribute, $value, $parameters) |
||
164 | { |
||
165 | return $this->runIsoCodesValidator(\IsoCodes\Gtin12::class, $value); |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * Validate a GTIN-13 code |
||
170 | * |
||
171 | * @param $attribute |
||
172 | * @param $value |
||
173 | * @param $parameters |
||
174 | * @return mixed |
||
175 | */ |
||
176 | public function validateGtin13($attribute, $value, $parameters) |
||
177 | { |
||
178 | return $this->runIsoCodesValidator(\IsoCodes\Gtin13::class, $value); |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * Validate a GTIN-14 code |
||
183 | * |
||
184 | * @param $attribute |
||
185 | * @param $value |
||
186 | * @param $parameters |
||
187 | * @return mixed |
||
188 | */ |
||
189 | public function validateGtin14($attribute, $value, $parameters) |
||
190 | { |
||
191 | return $this->runIsoCodesValidator(\IsoCodes\Gtin14::class, $value); |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * Validate an IBAN |
||
196 | * |
||
197 | * @param $attribute |
||
198 | * @param $value |
||
199 | * @param $parameters |
||
200 | * @return mixed |
||
201 | */ |
||
202 | public function validateIban($attribute, $value, $parameters) |
||
203 | { |
||
204 | return $this->runIsoCodesValidator(\IsoCodes\Iban::class, $value); |
||
205 | } |
||
206 | |||
207 | /** |
||
208 | * Validate a "numéro de sécurité sociale" (INSEE) |
||
209 | * |
||
210 | * @param $attribute |
||
211 | * @param $value |
||
212 | * @param $parameters |
||
213 | * @return mixed |
||
214 | */ |
||
215 | public function validateInsee($attribute, $value, $parameters) |
||
216 | { |
||
217 | return $this->runIsoCodesValidator(\IsoCodes\Insee::class, $value); |
||
218 | } |
||
219 | |||
220 | /** |
||
221 | * Validate an IP address |
||
222 | * |
||
223 | * @param $attribute |
||
224 | * @param $value |
||
225 | * @param $parameters |
||
226 | * @return mixed |
||
227 | */ |
||
228 | public function validateIpaddress($attribute, $value, $parameters) |
||
229 | { |
||
230 | return $this->runIsoCodesValidator(\IsoCodes\IP::class, $value); |
||
231 | } |
||
232 | |||
233 | /** |
||
234 | * Validate an ISBN |
||
235 | * |
||
236 | * @param $attribute |
||
237 | * @param $value |
||
238 | * @param $parameters |
||
239 | * @return mixed |
||
240 | */ |
||
241 | public function validateIsbn($attribute, $value, $parameters) |
||
242 | { |
||
243 | $this->requireParameterCount(1, $parameters, 'isbn'); |
||
244 | $type = Arr::get($this->data, $parameters[0]); |
||
245 | |||
246 | return $this->runIsoCodesValidator(\IsoCodes\Isbn::class, $value, $type); |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * Validate an "International Securities Identification Number" (ISIN) |
||
251 | * |
||
252 | * @param $attribute |
||
253 | * @param $value |
||
254 | * @param $parameters |
||
255 | * @return mixed |
||
256 | */ |
||
257 | public function validateIsin($attribute, $value, $parameters) |
||
258 | { |
||
259 | return $this->runIsoCodesValidator(\IsoCodes\Isin::class, $value); |
||
260 | } |
||
261 | |||
262 | /** |
||
263 | * Validate an "International Standard Music Number" or ISMN (ISO 10957) |
||
264 | * |
||
265 | * @param $attribute |
||
266 | * @param $value |
||
267 | * @param $parameters |
||
268 | * @return mixed |
||
269 | */ |
||
270 | public function validateIsmn($attribute, $value, $parameters) |
||
271 | { |
||
272 | return $this->runIsoCodesValidator(\IsoCodes\Ismn::class, $value); |
||
273 | } |
||
274 | |||
275 | /** |
||
276 | * Validate an "International Standard Musical Work Code" (ISWC) |
||
277 | * |
||
278 | * @param $attribute |
||
279 | * @param $value |
||
280 | * @param $parameters |
||
281 | * @return mixed |
||
282 | */ |
||
283 | public function validateIswc($attribute, $value, $parameters) |
||
284 | { |
||
285 | return $this->runIsoCodesValidator(\IsoCodes\Iswc::class, $value); |
||
286 | } |
||
287 | |||
288 | /** |
||
289 | * Validate a MAC address |
||
290 | * |
||
291 | * @param $attribute |
||
292 | * @param $value |
||
293 | * @param $parameters |
||
294 | * @return mixed |
||
295 | */ |
||
296 | public function validateMac($attribute, $value, $parameters) |
||
297 | { |
||
298 | return $this->runIsoCodesValidator(\IsoCodes\Mac::class, $value); |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * Validate a "Número de Identificación Fiscal" (NIF) |
||
303 | * |
||
304 | * @param $attribute |
||
305 | * @param $value |
||
306 | * @param $parameters |
||
307 | * @return mixed |
||
308 | */ |
||
309 | public function validateNif($attribute, $value, $parameters) |
||
310 | { |
||
311 | return $this->runIsoCodesValidator(\IsoCodes\Nif::class, $value); |
||
312 | } |
||
313 | |||
314 | /** |
||
315 | * Validate a "Organisme Type12 Norme B2" |
||
316 | * |
||
317 | * @param $attribute |
||
318 | * @param $value |
||
319 | * @param $parameters |
||
320 | * @return mixed |
||
321 | */ |
||
322 | public function validateOrganismeType12NormeB2($attribute, $value, $parameters) |
||
323 | { |
||
324 | $this->requireParameterCount(1, $parameters, 'organisme_type12_norme_b2'); |
||
325 | $clef = Arr::get($this->data, $parameters[0]); |
||
326 | |||
327 | return $this->runIsoCodesValidator(\IsoCodes\OrganismeType12NormeB2::class, $value, $clef); |
||
328 | } |
||
329 | |||
330 | /** |
||
331 | * Validate a phone number |
||
332 | * |
||
333 | * @param $attribute |
||
334 | * @param $value |
||
335 | * @param $parameters |
||
336 | * @return mixed |
||
337 | */ |
||
338 | public function validatePhonenumber($attribute, $value, $parameters) |
||
339 | { |
||
340 | $this->requireParameterCount(1, $parameters, 'phonenumber'); |
||
341 | $country = Arr::get($this->data, $parameters[0]); |
||
342 | |||
343 | return $this->runIsoCodesValidator(\IsoCodes\PhoneNumber::class, $value, $country); |
||
344 | } |
||
345 | |||
346 | /** |
||
347 | * Validate a Stock Exchange Daily Official List (SEDOL) |
||
348 | * |
||
349 | * @param $attribute |
||
350 | * @param $value |
||
351 | * @param $parameters |
||
352 | * @return mixed |
||
353 | */ |
||
354 | public function validateSedol($attribute, $value, $parameters) |
||
355 | { |
||
356 | return $this->runIsoCodesValidator(\IsoCodes\Sedol::class, $value); |
||
357 | } |
||
358 | |||
359 | /** |
||
360 | * Validate "Système d’Identification du Répertoire des Entreprises" (SIREN) |
||
361 | * |
||
362 | * @param $attribute |
||
363 | * @param $value |
||
364 | * @param $parameters |
||
365 | * @return mixed |
||
366 | */ |
||
367 | public function validateSiren($attribute, $value, $parameters) |
||
368 | { |
||
369 | return $this->runIsoCodesValidator(\IsoCodes\Siren::class, $value); |
||
370 | } |
||
371 | |||
372 | /** |
||
373 | * Validate "Système d’Identification du Répertoire des ETablissements" (SIRET) |
||
374 | * |
||
375 | * @param $attribute |
||
376 | * @param $value |
||
377 | * @param $parameters |
||
378 | * @return mixed |
||
379 | */ |
||
380 | public function validateSiret($attribute, $value, $parameters) |
||
381 | { |
||
382 | return $this->runIsoCodesValidator(\IsoCodes\Siret::class, $value); |
||
383 | } |
||
384 | |||
385 | /** |
||
386 | * Validate a European/International Article Number (SSCC) |
||
387 | * |
||
388 | * @param $attribute |
||
389 | * @param $value |
||
390 | * @param $parameters |
||
391 | * @return mixed |
||
392 | */ |
||
393 | public function validateSscc($attribute, $value, $parameters) |
||
394 | { |
||
395 | return $this->runIsoCodesValidator(\IsoCodes\Sscc::class, $value); |
||
396 | } |
||
397 | |||
398 | /** |
||
399 | * Validate a Social Security Number (SSN) |
||
400 | * |
||
401 | * @param $attribute |
||
402 | * @param $value |
||
403 | * @param $parameters |
||
404 | * @return mixed |
||
405 | */ |
||
406 | public function validateSsn($attribute, $value, $parameters) |
||
407 | { |
||
408 | return $this->runIsoCodesValidator(\IsoCodes\Ssn::class, $value); |
||
409 | } |
||
410 | |||
411 | /** |
||
412 | * Validate structured communication |
||
413 | * |
||
414 | * @param $attribute |
||
415 | * @param $value |
||
416 | * @param $parameters |
||
417 | * @return mixed |
||
418 | */ |
||
419 | public function validateStructuredCommunication($attribute, $value, $parameters) |
||
420 | { |
||
421 | return $this->runIsoCodesValidator(\IsoCodes\StructuredCommunication::class, $value); |
||
422 | } |
||
423 | |||
424 | /** |
||
425 | * Validate a SWIFT/BIC |
||
426 | * |
||
427 | * @param $attribute |
||
428 | * @param $value |
||
429 | * @param $parameters |
||
430 | * @return mixed |
||
431 | */ |
||
432 | public function validateSwiftBic($attribute, $value, $parameters) |
||
433 | { |
||
434 | return $this->runIsoCodesValidator(\IsoCodes\SwiftBic::class, $value); |
||
435 | } |
||
436 | |||
437 | /** |
||
438 | * Validate a Unique Device Identification |
||
439 | * |
||
440 | * @param $attribute |
||
441 | * @param $value |
||
442 | * @param $parameters |
||
443 | * @return mixed |
||
444 | */ |
||
445 | public function validateUdi($attribute, $value, $parameters) |
||
446 | { |
||
447 | return $this->runIsoCodesValidator(\IsoCodes\Udi::class, $value); |
||
448 | } |
||
449 | |||
450 | /** |
||
451 | * Validate a UK National Insurance Number |
||
452 | * |
||
453 | * @param $attribute |
||
454 | * @param $value |
||
455 | * @param $parameters |
||
456 | * @return mixed |
||
457 | */ |
||
458 | public function validateUknin($attribute, $value, $parameters) |
||
459 | { |
||
460 | return $this->runIsoCodesValidator(\IsoCodes\Uknin::class, $value); |
||
461 | } |
||
462 | |||
463 | /** |
||
464 | * Validate a Universal Product Code |
||
465 | * |
||
466 | * @param $attribute |
||
467 | * @param $value |
||
468 | * @param $parameters |
||
469 | * @return mixed |
||
470 | */ |
||
471 | public function validateUpca($attribute, $value, $parameters) |
||
472 | { |
||
473 | return $this->runIsoCodesValidator(\IsoCodes\Upca::class, $value); |
||
474 | } |
||
475 | |||
476 | /** |
||
477 | * Validate Value Added Tax (VAT) |
||
478 | * |
||
479 | * @param $attribute |
||
480 | * @param $value |
||
481 | * @param $parameters |
||
482 | * @return mixed |
||
483 | */ |
||
484 | public function validateVat($attribute, $value, $parameters) |
||
485 | { |
||
486 | return $this->runIsoCodesValidator(\IsoCodes\Vat::class, $value); |
||
487 | } |
||
488 | |||
489 | /** |
||
490 | * Validate a zip code |
||
491 | * |
||
492 | * @param $attribute |
||
493 | * @param $value |
||
494 | * @param $parameters |
||
495 | * @return mixed |
||
496 | */ |
||
497 | public function _validateZipcode($attribute, $value, $parameters) |
||
498 | { |
||
499 | $this->requireParameterCount(1, $parameters, 'zipcode'); |
||
500 | $country = Arr::get($this->data, $parameters[0]); |
||
501 | |||
502 | return $this->runIsoCodesValidator(\IsoCodes\ZipCode::class, $value, $country); |
||
503 | } |
||
504 | |||
505 | public function validateZipcode($attribute, $value, $parameters) |
||
506 | { |
||
507 | $this->requireParameterCount(1, $parameters, 'zipcode'); |
||
508 | |||
509 | if ($keys = $this->getExplicitKeys($attribute)) { |
||
510 | $parameters = $this->replaceAsterisksInParameters($parameters, $keys); |
||
511 | } |
||
512 | |||
513 | $country = Arr::get($this->data, $parameters[0]); |
||
514 | |||
515 | return $this->runIsoCodesValidator(\IsoCodes\ZipCode::class, $value, $country); |
||
516 | } |
||
517 | /** |
||
518 | * Execute the validation function |
||
519 | * and catch every other Exception from underlying libraries |
||
520 | * so we will only display the Laravel validation error |
||
521 | * |
||
522 | * @param $validator |
||
523 | * @param $value |
||
524 | * @param string $reference |
||
525 | * @return mixed |
||
526 | */ |
||
527 | protected function runIsoCodesValidator($validator, $value, $reference = '') |
||
528 | { |
||
529 | try { |
||
530 | if (empty($reference)) { |
||
531 | return call_user_func($validator . '::validate', $value); |
||
532 | } |
||
533 | |||
534 | return call_user_func($validator . '::validate', $value, $reference); |
||
535 | } catch (Exception $e) { |
||
536 | // do nothing |
||
537 | } |
||
538 | } |
||
539 | |||
540 | /** |
||
541 | * Replace all country place-holders |
||
542 | * |
||
543 | * @param $message |
||
544 | * @param $parameter |
||
545 | * @return mixed |
||
546 | */ |
||
547 | protected function countryReplacer($message, $parameter) |
||
548 | { |
||
549 | return str_replace(':country', Arr::get($this->data, $parameter[0]), $message); |
||
550 | } |
||
551 | |||
552 | /** |
||
553 | * Replace all value place-holders |
||
554 | * |
||
555 | * @param $message |
||
556 | * @param $attribute |
||
557 | * @return mixed |
||
558 | */ |
||
559 | protected function valueReplacer($message, $attribute) |
||
560 | { |
||
561 | return str_replace(':value', $this->getValue($attribute), $message); |
||
562 | } |
||
563 | |||
564 | /** |
||
565 | * Replace all place-holders for the bban rule |
||
566 | * |
||
567 | * @param $message |
||
568 | * @param $attribute |
||
569 | * @param $rule |
||
570 | * @param $parameter |
||
571 | * @return mixed |
||
572 | */ |
||
573 | public function replaceBban($message, $attribute, $rule, $parameter) |
||
574 | { |
||
575 | return $this->valueReplacer($message, $attribute); |
||
576 | } |
||
577 | |||
578 | /** |
||
579 | * Replace all place-holders for the bsn rule |
||
580 | * |
||
581 | * @param $message |
||
582 | * @param $attribute |
||
583 | * @param $rule |
||
584 | * @param $parameter |
||
585 | * @return mixed |
||
586 | */ |
||
587 | public function replaceBsn($message, $attribute, $rule, $parameter) |
||
588 | { |
||
589 | return $this->valueReplacer($message, $attribute); |
||
590 | } |
||
591 | |||
592 | /** |
||
593 | * Replace all place-holders for the cif rule |
||
594 | * |
||
595 | * @param $message |
||
596 | * @param $attribute |
||
597 | * @param $rule |
||
598 | * @param $parameter |
||
599 | * @return mixed |
||
600 | */ |
||
601 | public function replaceCif($message, $attribute, $rule, $parameter) |
||
602 | { |
||
603 | return $this->valueReplacer($message, $attribute); |
||
604 | } |
||
605 | |||
606 | /** |
||
607 | * Replace all place-holders for the creditcard rule |
||
608 | * |
||
609 | * @param $message |
||
610 | * @param $attribute |
||
611 | * @param $rule |
||
612 | * @param $parameter |
||
613 | * @return mixed |
||
614 | */ |
||
615 | public function replaceCreditcard($message, $attribute, $rule, $parameter) |
||
616 | { |
||
617 | return $this->valueReplacer($message, $attribute); |
||
618 | } |
||
619 | |||
620 | /** |
||
621 | * Replace all place-holders for the ena8 rule |
||
622 | * |
||
623 | * @param $message |
||
624 | * @param $attribute |
||
625 | * @param $rule |
||
626 | * @param $parameter |
||
627 | * @return mixed |
||
628 | */ |
||
629 | public function replaceEan8($message, $attribute, $rule, $parameter) |
||
630 | { |
||
631 | return $this->valueReplacer($message, $attribute); |
||
632 | } |
||
633 | |||
634 | /** |
||
635 | * Replace all place-holders for the ean13 rule |
||
636 | * |
||
637 | * @param $message |
||
638 | * @param $attribute |
||
639 | * @param $rule |
||
640 | * @param $parameter |
||
641 | * @return mixed |
||
642 | */ |
||
643 | public function replaceEan13($message, $attribute, $rule, $parameter) |
||
644 | { |
||
645 | return $this->valueReplacer($message, $attribute); |
||
646 | } |
||
647 | |||
648 | /** |
||
649 | * Replace all place-holders for the gdti rule |
||
650 | * |
||
651 | * @param $message |
||
652 | * @param $attribute |
||
653 | * @param $rule |
||
654 | * @param $parameter |
||
655 | * @return mixed |
||
656 | */ |
||
657 | public function replaceGdti($message, $attribute, $rule, $parameter) |
||
658 | { |
||
659 | return $this->valueReplacer($message, $attribute); |
||
660 | } |
||
661 | |||
662 | /** |
||
663 | * Replace all place-holders for the gln rule |
||
664 | * |
||
665 | * @param $message |
||
666 | * @param $attribute |
||
667 | * @param $rule |
||
668 | * @param $parameter |
||
669 | * @return mixed |
||
670 | */ |
||
671 | public function replaceGln($message, $attribute, $rule, $parameter) |
||
672 | { |
||
673 | return $this->valueReplacer($message, $attribute); |
||
674 | } |
||
675 | |||
676 | /** |
||
677 | * Replace all place-holders for the grai rule |
||
678 | * |
||
679 | * @param $message |
||
680 | * @param $attribute |
||
681 | * @param $rule |
||
682 | * @param $parameter |
||
683 | * @return mixed |
||
684 | */ |
||
685 | public function replaceGrai($message, $attribute, $rule, $parameter) |
||
686 | { |
||
687 | return $this->valueReplacer($message, $attribute); |
||
688 | } |
||
689 | |||
690 | /** |
||
691 | * Replace all place-holders for the gsrn rule |
||
692 | * |
||
693 | * @param $message |
||
694 | * @param $attribute |
||
695 | * @param $rule |
||
696 | * @param $parameter |
||
697 | * @return mixed |
||
698 | */ |
||
699 | public function replaceGsrn($message, $attribute, $rule, $parameter) |
||
700 | { |
||
701 | return $this->valueReplacer($message, $attribute); |
||
702 | } |
||
703 | |||
704 | /** |
||
705 | * Replace all place-holders for the gitin8 rule |
||
706 | * |
||
707 | * @param $message |
||
708 | * @param $attribute |
||
709 | * @param $rule |
||
710 | * @param $parameter |
||
711 | * @return mixed |
||
712 | */ |
||
713 | public function replaceGtin8($message, $attribute, $rule, $parameter) |
||
714 | { |
||
715 | return $this->valueReplacer($message, $attribute); |
||
716 | } |
||
717 | |||
718 | /** |
||
719 | * Replace all place-holders for the gtin12 rule |
||
720 | * |
||
721 | * @param $message |
||
722 | * @param $attribute |
||
723 | * @param $rule |
||
724 | * @param $parameter |
||
725 | * @return mixed |
||
726 | */ |
||
727 | public function replaceGtin12($message, $attribute, $rule, $parameter) |
||
728 | { |
||
729 | return $this->valueReplacer($message, $attribute); |
||
730 | } |
||
731 | |||
732 | /** |
||
733 | * Replace all place-holders for the gtin13 rule |
||
734 | * |
||
735 | * @param $message |
||
736 | * @param $attribute |
||
737 | * @param $rule |
||
738 | * @param $parameter |
||
739 | * @return mixed |
||
740 | */ |
||
741 | public function replaceGtin13($message, $attribute, $rule, $parameter) |
||
742 | { |
||
743 | return $this->valueReplacer($message, $attribute); |
||
744 | } |
||
745 | |||
746 | /** |
||
747 | * Replace all place-holders for the gtin14 rule |
||
748 | * |
||
749 | * @param $message |
||
750 | * @param $attribute |
||
751 | * @param $rule |
||
752 | * @param $parameter |
||
753 | * @return mixed |
||
754 | */ |
||
755 | public function replaceGtin14($message, $attribute, $rule, $parameter) |
||
756 | { |
||
757 | return $this->valueReplacer($message, $attribute); |
||
758 | } |
||
759 | |||
760 | /** |
||
761 | * Replace all place-holders for the iban rule |
||
762 | * |
||
763 | * @param $message |
||
764 | * @param $attribute |
||
765 | * @param $rule |
||
766 | * @param $parameter |
||
767 | * @return mixed |
||
768 | */ |
||
769 | public function replaceIban($message, $attribute, $rule, $parameter) |
||
770 | { |
||
771 | return $this->valueReplacer($message, $attribute); |
||
772 | } |
||
773 | |||
774 | /** |
||
775 | * Replace all place-holders for the insee rule |
||
776 | * |
||
777 | * @param $message |
||
778 | * @param $attribute |
||
779 | * @param $rule |
||
780 | * @param $parameter |
||
781 | * @return mixed |
||
782 | */ |
||
783 | public function replaceInsee($message, $attribute, $rule, $parameter) |
||
784 | { |
||
785 | return $this->valueReplacer($message, $attribute); |
||
786 | } |
||
787 | |||
788 | /** |
||
789 | * Replace all place-holders for the ipaddress rule |
||
790 | * |
||
791 | * @param $message |
||
792 | * @param $attribute |
||
793 | * @param $rule |
||
794 | * @param $parameter |
||
795 | * @return mixed |
||
796 | */ |
||
797 | public function replaceIpaddress($message, $attribute, $rule, $parameter) |
||
798 | { |
||
799 | return $this->valueReplacer($message, $attribute); |
||
800 | } |
||
801 | |||
802 | /** |
||
803 | * Replace all place-holders for the isbn rule |
||
804 | * |
||
805 | * @param $message |
||
806 | * @param $attribute |
||
807 | * @param $rule |
||
808 | * @param $parameter |
||
809 | * @return mixed |
||
810 | */ |
||
811 | public function replaceIsbn($message, $attribute, $rule, $parameter) |
||
812 | { |
||
813 | return $this->valueReplacer($message, $attribute); |
||
814 | } |
||
815 | |||
816 | /** |
||
817 | * Replace all place-holders for the isin rule |
||
818 | * |
||
819 | * @param $message |
||
820 | * @param $attribute |
||
821 | * @param $rule |
||
822 | * @param $parameter |
||
823 | * @return mixed |
||
824 | */ |
||
825 | public function replaceIsin($message, $attribute, $rule, $parameter) |
||
826 | { |
||
827 | return $this->valueReplacer($message, $attribute); |
||
828 | } |
||
829 | |||
830 | /** |
||
831 | * Replace all place-holders for the ismn rule |
||
832 | * |
||
833 | * @param $message |
||
834 | * @param $attribute |
||
835 | * @param $rule |
||
836 | * @param $parameter |
||
837 | * @return mixed |
||
838 | */ |
||
839 | public function replaceIsmn($message, $attribute, $rule, $parameter) |
||
842 | } |
||
843 | |||
844 | /** |
||
845 | * Replace all place-holders for the iswc rule |
||
846 | * |
||
847 | * @param $message |
||
848 | * @param $attribute |
||
849 | * @param $rule |
||
850 | * @param $parameter |
||
851 | * @return mixed |
||
852 | */ |
||
853 | public function replaceIswc($message, $attribute, $rule, $parameter) |
||
856 | } |
||
857 | |||
858 | /** |
||
859 | * Replace all place-holders for the mac rule |
||
860 | * |
||
861 | * @param $message |
||
862 | * @param $attribute |
||
863 | * @param $rule |
||
864 | * @param $parameter |
||
865 | * @return mixed |
||
866 | */ |
||
867 | public function replaceMac($message, $attribute, $rule, $parameter) |
||
868 | { |
||
869 | return $this->valueReplacer($message, $attribute); |
||
870 | } |
||
871 | |||
872 | /** |
||
873 | * Replace all place-holders for the nif rule |
||
874 | * |
||
875 | * @param $message |
||
876 | * @param $attribute |
||
877 | * @param $rule |
||
878 | * @param $parameter |
||
879 | * @return mixed |
||
880 | */ |
||
881 | public function replaceNif($message, $attribute, $rule, $parameter) |
||
882 | { |
||
883 | return $this->valueReplacer($message, $attribute); |
||
884 | } |
||
885 | |||
886 | /** |
||
887 | * Replace all place-holders for the organisme_type12_norme_b2 rule |
||
888 | * |
||
889 | * @param $message |
||
890 | * @param $attribute |
||
891 | * @param $rule |
||
892 | * @param $parameter |
||
893 | * @return mixed |
||
894 | */ |
||
895 | public function replaceOrganismeType12NormeB2($message, $attribute, $rule, $parameter) |
||
896 | { |
||
897 | return $this->valueReplacer($message, $attribute); |
||
898 | } |
||
899 | |||
900 | /** |
||
901 | * Replace all place-holders for the phonenumber rule |
||
902 | * |
||
903 | * @param $message |
||
904 | * @param $attribute |
||
905 | * @param $rule |
||
906 | * @param $parameter |
||
907 | * @return mixed |
||
908 | */ |
||
909 | protected function replacePhonenumber($message, $attribute, $rule, $parameter) |
||
910 | { |
||
911 | $message = $this->valueReplacer($message, $attribute); |
||
912 | $message = $this->countryReplacer($message, $parameter[0]); |
||
913 | |||
914 | return $message; |
||
915 | } |
||
916 | |||
917 | /** |
||
918 | * Replace all place-holders for the sedol rule |
||
919 | * |
||
920 | * @param $message |
||
921 | * @param $attribute |
||
922 | * @param $rule |
||
923 | * @param $parameter |
||
924 | * @return mixed |
||
925 | */ |
||
926 | public function replaceSedol($message, $attribute, $rule, $parameter) |
||
927 | { |
||
928 | return $this->valueReplacer($message, $attribute); |
||
929 | } |
||
930 | |||
931 | /** |
||
932 | * Replace all place-holders for the siren rule |
||
933 | * |
||
934 | * @param $message |
||
935 | * @param $attribute |
||
936 | * @param $rule |
||
937 | * @param $parameter |
||
938 | * @return mixed |
||
939 | */ |
||
940 | public function replaceSiren($message, $attribute, $rule, $parameter) |
||
941 | { |
||
942 | return $this->valueReplacer($message, $attribute); |
||
943 | } |
||
944 | |||
945 | /** |
||
946 | * Replace all place-holders for the siret rule |
||
947 | * |
||
948 | * @param $message |
||
949 | * @param $attribute |
||
950 | * @param $rule |
||
951 | * @param $parameter |
||
952 | * @return mixed |
||
953 | */ |
||
954 | public function replaceSiret($message, $attribute, $rule, $parameter) |
||
955 | { |
||
956 | return $this->valueReplacer($message, $attribute); |
||
957 | } |
||
958 | |||
959 | /** |
||
960 | * Replace all place-holders for the sscc rule |
||
961 | * |
||
962 | * @param $message |
||
963 | * @param $attribute |
||
964 | * @param $rule |
||
965 | * @param $parameter |
||
966 | * @return mixed |
||
967 | */ |
||
968 | public function replaceSscc($message, $attribute, $rule, $parameter) |
||
969 | { |
||
970 | return $this->valueReplacer($message, $attribute); |
||
971 | } |
||
972 | |||
973 | /** |
||
974 | * Replace all place-holders for the ssn rule |
||
975 | * |
||
976 | * @param $message |
||
977 | * @param $attribute |
||
978 | * @param $rule |
||
979 | * @param $parameter |
||
980 | * @return mixed |
||
981 | */ |
||
982 | public function replaceSSn($message, $attribute, $rule, $parameter) |
||
983 | { |
||
984 | return $this->valueReplacer($message, $attribute); |
||
985 | } |
||
986 | |||
987 | /** |
||
988 | * Replace all place-holders for the structured_communication rule |
||
989 | * |
||
990 | * @param $message |
||
991 | * @param $attribute |
||
992 | * @param $rule |
||
993 | * @param $parameter |
||
994 | * @return mixed |
||
995 | */ |
||
996 | public function replaceStructuredCommunication($message, $attribute, $rule, $parameter) |
||
997 | { |
||
998 | return $this->valueReplacer($message, $attribute); |
||
999 | } |
||
1000 | |||
1001 | /** |
||
1002 | * Replace all place-holders for the swift_bic rule |
||
1003 | * |
||
1004 | * @param $message |
||
1005 | * @param $attribute |
||
1006 | * @param $rule |
||
1007 | * @param $parameter |
||
1008 | * @return mixed |
||
1009 | */ |
||
1010 | public function replaceSwiftBic($message, $attribute, $rule, $parameter) |
||
1011 | { |
||
1012 | return $this->valueReplacer($message, $attribute); |
||
1013 | } |
||
1014 | |||
1015 | /** |
||
1016 | * Replace all place-holders for the udi rule |
||
1017 | * |
||
1018 | * @param $message |
||
1019 | * @param $attribute |
||
1020 | * @param $rule |
||
1021 | * @param $parameter |
||
1022 | * @return mixed |
||
1023 | */ |
||
1024 | public function replaceUdi($message, $attribute, $rule, $parameter) |
||
1027 | } |
||
1028 | |||
1029 | /** |
||
1030 | * Replace all place-holders for the uknin rule |
||
1031 | * |
||
1032 | * @param $message |
||
1033 | * @param $attribute |
||
1034 | * @param $rule |
||
1035 | * @param $parameter |
||
1036 | * @return mixed |
||
1037 | */ |
||
1038 | public function replaceUknin($message, $attribute, $rule, $parameter) |
||
1039 | { |
||
1040 | return $this->valueReplacer($message, $attribute); |
||
1041 | } |
||
1042 | |||
1043 | /** |
||
1044 | * Replace all place-holders for the upca rule |
||
1045 | * |
||
1046 | * @param $message |
||
1047 | * @param $attribute |
||
1048 | * @param $rule |
||
1049 | * @param $parameter |
||
1050 | * @return mixed |
||
1051 | */ |
||
1052 | public function replaceUpca($message, $attribute, $rule, $parameter) |
||
1053 | { |
||
1054 | return $this->valueReplacer($message, $attribute); |
||
1055 | } |
||
1056 | |||
1057 | /** |
||
1058 | * Replace all place-holders for the vat rule |
||
1059 | * |
||
1060 | * @param $message |
||
1061 | * @param $attribute |
||
1062 | * @param $rule |
||
1063 | * @param $parameter |
||
1064 | * @return mixed |
||
1065 | */ |
||
1066 | public function replaceVat($message, $attribute, $rule, $parameter) |
||
1067 | { |
||
1068 | return $this->valueReplacer($message, $attribute); |
||
1069 | } |
||
1070 | |||
1071 | /** |
||
1072 | * Replace all place-holders for the zipcode rule |
||
1073 | * |
||
1074 | * @param $message |
||
1075 | * @param $attribute |
||
1076 | * @param $rule |
||
1077 | * @param $parameter |
||
1078 | * @return mixed |
||
1079 | */ |
||
1080 | public function replaceZipcode($message, $attribute, $rule, $parameter) |
||
1081 | { |
||
1082 | var_dump($message, $attribute, $this->getValue($attribute), $parameter); |
||
1083 | |||
1084 | var_dump( |
||
1085 | Arr::get($this->data, 'data.0.country') |
||
1086 | ); |
||
1087 | $message = $this->valueReplacer($message, $attribute); |
||
1088 | var_dump($message); |
||
1089 | $message = $this->valueReplacer($message, $parameter[0]); |
||
1090 | var_dump($message); |
||
1091 | // $message = $this->countryReplacer($message, $parameter); |
||
1092 | // dd($message, $attribute, $rule, $parameter[0]); |
||
1093 | return $message; |
||
1094 | } |
||
1095 | |||
1096 | /** |
||
1097 | * Get the explicit keys from an attribute flattened with dot notation. |
||
1098 | * |
||
1099 | * E.g. 'foo.1.bar.spark.baz' -> [1, 'spark'] for 'foo.*.bar.*.baz' |
||
1100 | * |
||
1101 | * @param string $attribute |
||
1102 | * @return array |
||
1103 | */ |
||
1104 | protected function getExplicitKeys($attribute) |
||
1112 | } |
||
1113 | |||
1114 | /** |
||
1115 | * Get the primary attribute name. |
||
1116 | * |
||
1117 | * For example, if "name.0" is given, "name.*" will be returned. |
||
1118 | * |
||
1119 | * @param string $attribute |
||
1120 | * @return string |
||
1121 | */ |
||
1122 | protected function getPrimaryAttribute($attribute) |
||
1130 | } |
||
1131 | } |
||
1132 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.