1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pixelpeter\IsoCodesValidation; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use Exception; |
7
|
|
|
use Illuminate\Support\Arr; |
8
|
|
|
use Illuminate\Validation\Validator as BaseValidator; |
9
|
|
|
|
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
|
/** |
506
|
|
|
* Execute the validation function |
507
|
|
|
* and catch every other Exception from underlying libraries |
508
|
|
|
* so we will only display the Laravel validation error |
509
|
|
|
* |
510
|
|
|
* @param $validator |
511
|
|
|
* @param $value |
512
|
|
|
* @param string $reference |
513
|
|
|
* @return mixed |
514
|
|
|
*/ |
515
|
|
|
protected function runIsoCodesValidator($validator, $value, $reference = '') |
516
|
|
|
{ |
517
|
|
|
try { |
518
|
|
|
if (empty($reference)) { |
519
|
|
|
return call_user_func($validator . '::validate', $value); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
return call_user_func($validator . '::validate', $value, $reference); |
523
|
|
|
} catch (Exception $e) { |
524
|
|
|
// do nothing |
525
|
|
|
} |
526
|
|
|
} |
527
|
|
|
|
528
|
|
|
/** |
529
|
|
|
* Replace all country place-holders |
530
|
|
|
* |
531
|
|
|
* @param $message |
532
|
|
|
* @param $parameter |
533
|
|
|
* @return mixed |
534
|
|
|
*/ |
535
|
|
|
protected function countryReplacer($message, $parameter) |
536
|
|
|
{ |
537
|
|
|
return str_replace(':country', Arr::get($this->data, $parameter[0]), $message); |
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
/** |
541
|
|
|
* Replace all value place-holders |
542
|
|
|
* |
543
|
|
|
* @param $message |
544
|
|
|
* @param $attribute |
545
|
|
|
* @return mixed |
546
|
|
|
*/ |
547
|
|
|
protected function valueReplacer($message, $attribute) |
548
|
|
|
{ |
549
|
|
|
return str_replace(':value', $this->getValue($attribute), $message); |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
/** |
553
|
|
|
* Replace all place-holders for the bban rule |
554
|
|
|
* |
555
|
|
|
* @param $message |
556
|
|
|
* @param $attribute |
557
|
|
|
* @param $rule |
558
|
|
|
* @param $parameter |
559
|
|
|
* @return mixed |
560
|
|
|
*/ |
561
|
|
|
public function replaceBban($message, $attribute, $rule, $parameter) |
|
|
|
|
562
|
|
|
{ |
563
|
|
|
return $this->valueReplacer($message, $attribute); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* Replace all place-holders for the bsn rule |
568
|
|
|
* |
569
|
|
|
* @param $message |
570
|
|
|
* @param $attribute |
571
|
|
|
* @param $rule |
572
|
|
|
* @param $parameter |
573
|
|
|
* @return mixed |
574
|
|
|
*/ |
575
|
|
|
public function replaceBsn($message, $attribute, $rule, $parameter) |
|
|
|
|
576
|
|
|
{ |
577
|
|
|
return $this->valueReplacer($message, $attribute); |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
/** |
581
|
|
|
* Replace all place-holders for the cif rule |
582
|
|
|
* |
583
|
|
|
* @param $message |
584
|
|
|
* @param $attribute |
585
|
|
|
* @param $rule |
586
|
|
|
* @param $parameter |
587
|
|
|
* @return mixed |
588
|
|
|
*/ |
589
|
|
|
public function replaceCif($message, $attribute, $rule, $parameter) |
|
|
|
|
590
|
|
|
{ |
591
|
|
|
return $this->valueReplacer($message, $attribute); |
592
|
|
|
} |
593
|
|
|
|
594
|
|
|
/** |
595
|
|
|
* Replace all place-holders for the creditcard rule |
596
|
|
|
* |
597
|
|
|
* @param $message |
598
|
|
|
* @param $attribute |
599
|
|
|
* @param $rule |
600
|
|
|
* @param $parameter |
601
|
|
|
* @return mixed |
602
|
|
|
*/ |
603
|
|
|
public function replaceCreditcard($message, $attribute, $rule, $parameter) |
|
|
|
|
604
|
|
|
{ |
605
|
|
|
return $this->valueReplacer($message, $attribute); |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* Replace all place-holders for the ena8 rule |
610
|
|
|
* |
611
|
|
|
* @param $message |
612
|
|
|
* @param $attribute |
613
|
|
|
* @param $rule |
614
|
|
|
* @param $parameter |
615
|
|
|
* @return mixed |
616
|
|
|
*/ |
617
|
|
|
public function replaceEan8($message, $attribute, $rule, $parameter) |
|
|
|
|
618
|
|
|
{ |
619
|
|
|
return $this->valueReplacer($message, $attribute); |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
/** |
623
|
|
|
* Replace all place-holders for the ean13 rule |
624
|
|
|
* |
625
|
|
|
* @param $message |
626
|
|
|
* @param $attribute |
627
|
|
|
* @param $rule |
628
|
|
|
* @param $parameter |
629
|
|
|
* @return mixed |
630
|
|
|
*/ |
631
|
|
|
public function replaceEan13($message, $attribute, $rule, $parameter) |
|
|
|
|
632
|
|
|
{ |
633
|
|
|
return $this->valueReplacer($message, $attribute); |
634
|
|
|
} |
635
|
|
|
|
636
|
|
|
/** |
637
|
|
|
* Replace all place-holders for the gdti rule |
638
|
|
|
* |
639
|
|
|
* @param $message |
640
|
|
|
* @param $attribute |
641
|
|
|
* @param $rule |
642
|
|
|
* @param $parameter |
643
|
|
|
* @return mixed |
644
|
|
|
*/ |
645
|
|
|
public function replaceGdti($message, $attribute, $rule, $parameter) |
|
|
|
|
646
|
|
|
{ |
647
|
|
|
return $this->valueReplacer($message, $attribute); |
648
|
|
|
} |
649
|
|
|
|
650
|
|
|
/** |
651
|
|
|
* Replace all place-holders for the gln rule |
652
|
|
|
* |
653
|
|
|
* @param $message |
654
|
|
|
* @param $attribute |
655
|
|
|
* @param $rule |
656
|
|
|
* @param $parameter |
657
|
|
|
* @return mixed |
658
|
|
|
*/ |
659
|
|
|
public function replaceGln($message, $attribute, $rule, $parameter) |
|
|
|
|
660
|
|
|
{ |
661
|
|
|
return $this->valueReplacer($message, $attribute); |
662
|
|
|
} |
663
|
|
|
|
664
|
|
|
/** |
665
|
|
|
* Replace all place-holders for the grai rule |
666
|
|
|
* |
667
|
|
|
* @param $message |
668
|
|
|
* @param $attribute |
669
|
|
|
* @param $rule |
670
|
|
|
* @param $parameter |
671
|
|
|
* @return mixed |
672
|
|
|
*/ |
673
|
|
|
public function replaceGrai($message, $attribute, $rule, $parameter) |
|
|
|
|
674
|
|
|
{ |
675
|
|
|
return $this->valueReplacer($message, $attribute); |
676
|
|
|
} |
677
|
|
|
|
678
|
|
|
/** |
679
|
|
|
* Replace all place-holders for the gsrn rule |
680
|
|
|
* |
681
|
|
|
* @param $message |
682
|
|
|
* @param $attribute |
683
|
|
|
* @param $rule |
684
|
|
|
* @param $parameter |
685
|
|
|
* @return mixed |
686
|
|
|
*/ |
687
|
|
|
public function replaceGsrn($message, $attribute, $rule, $parameter) |
|
|
|
|
688
|
|
|
{ |
689
|
|
|
return $this->valueReplacer($message, $attribute); |
690
|
|
|
} |
691
|
|
|
|
692
|
|
|
/** |
693
|
|
|
* Replace all place-holders for the gitin8 rule |
694
|
|
|
* |
695
|
|
|
* @param $message |
696
|
|
|
* @param $attribute |
697
|
|
|
* @param $rule |
698
|
|
|
* @param $parameter |
699
|
|
|
* @return mixed |
700
|
|
|
*/ |
701
|
|
|
public function replaceGtin8($message, $attribute, $rule, $parameter) |
|
|
|
|
702
|
|
|
{ |
703
|
|
|
return $this->valueReplacer($message, $attribute); |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
/** |
707
|
|
|
* Replace all place-holders for the gtin12 rule |
708
|
|
|
* |
709
|
|
|
* @param $message |
710
|
|
|
* @param $attribute |
711
|
|
|
* @param $rule |
712
|
|
|
* @param $parameter |
713
|
|
|
* @return mixed |
714
|
|
|
*/ |
715
|
|
|
public function replaceGtin12($message, $attribute, $rule, $parameter) |
|
|
|
|
716
|
|
|
{ |
717
|
|
|
return $this->valueReplacer($message, $attribute); |
718
|
|
|
} |
719
|
|
|
|
720
|
|
|
/** |
721
|
|
|
* Replace all place-holders for the gtin13 rule |
722
|
|
|
* |
723
|
|
|
* @param $message |
724
|
|
|
* @param $attribute |
725
|
|
|
* @param $rule |
726
|
|
|
* @param $parameter |
727
|
|
|
* @return mixed |
728
|
|
|
*/ |
729
|
|
|
public function replaceGtin13($message, $attribute, $rule, $parameter) |
|
|
|
|
730
|
|
|
{ |
731
|
|
|
return $this->valueReplacer($message, $attribute); |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
/** |
735
|
|
|
* Replace all place-holders for the gtin14 rule |
736
|
|
|
* |
737
|
|
|
* @param $message |
738
|
|
|
* @param $attribute |
739
|
|
|
* @param $rule |
740
|
|
|
* @param $parameter |
741
|
|
|
* @return mixed |
742
|
|
|
*/ |
743
|
|
|
public function replaceGtin14($message, $attribute, $rule, $parameter) |
|
|
|
|
744
|
|
|
{ |
745
|
|
|
return $this->valueReplacer($message, $attribute); |
746
|
|
|
} |
747
|
|
|
|
748
|
|
|
/** |
749
|
|
|
* Replace all place-holders for the iban rule |
750
|
|
|
* |
751
|
|
|
* @param $message |
752
|
|
|
* @param $attribute |
753
|
|
|
* @param $rule |
754
|
|
|
* @param $parameter |
755
|
|
|
* @return mixed |
756
|
|
|
*/ |
757
|
|
|
public function replaceIban($message, $attribute, $rule, $parameter) |
|
|
|
|
758
|
|
|
{ |
759
|
|
|
return $this->valueReplacer($message, $attribute); |
760
|
|
|
} |
761
|
|
|
|
762
|
|
|
/** |
763
|
|
|
* Replace all place-holders for the insee rule |
764
|
|
|
* |
765
|
|
|
* @param $message |
766
|
|
|
* @param $attribute |
767
|
|
|
* @param $rule |
768
|
|
|
* @param $parameter |
769
|
|
|
* @return mixed |
770
|
|
|
*/ |
771
|
|
|
public function replaceInsee($message, $attribute, $rule, $parameter) |
|
|
|
|
772
|
|
|
{ |
773
|
|
|
return $this->valueReplacer($message, $attribute); |
774
|
|
|
} |
775
|
|
|
|
776
|
|
|
/** |
777
|
|
|
* Replace all place-holders for the ipaddress rule |
778
|
|
|
* |
779
|
|
|
* @param $message |
780
|
|
|
* @param $attribute |
781
|
|
|
* @param $rule |
782
|
|
|
* @param $parameter |
783
|
|
|
* @return mixed |
784
|
|
|
*/ |
785
|
|
|
public function replaceIpaddress($message, $attribute, $rule, $parameter) |
|
|
|
|
786
|
|
|
{ |
787
|
|
|
return $this->valueReplacer($message, $attribute); |
788
|
|
|
} |
789
|
|
|
|
790
|
|
|
/** |
791
|
|
|
* Replace all place-holders for the isbn rule |
792
|
|
|
* |
793
|
|
|
* @param $message |
794
|
|
|
* @param $attribute |
795
|
|
|
* @param $rule |
796
|
|
|
* @param $parameter |
797
|
|
|
* @return mixed |
798
|
|
|
*/ |
799
|
|
|
public function replaceIsbn($message, $attribute, $rule, $parameter) |
|
|
|
|
800
|
|
|
{ |
801
|
|
|
return $this->valueReplacer($message, $attribute); |
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
/** |
805
|
|
|
* Replace all place-holders for the isin rule |
806
|
|
|
* |
807
|
|
|
* @param $message |
808
|
|
|
* @param $attribute |
809
|
|
|
* @param $rule |
810
|
|
|
* @param $parameter |
811
|
|
|
* @return mixed |
812
|
|
|
*/ |
813
|
|
|
public function replaceIsin($message, $attribute, $rule, $parameter) |
|
|
|
|
814
|
|
|
{ |
815
|
|
|
return $this->valueReplacer($message, $attribute); |
816
|
|
|
} |
817
|
|
|
|
818
|
|
|
/** |
819
|
|
|
* Replace all place-holders for the ismn rule |
820
|
|
|
* |
821
|
|
|
* @param $message |
822
|
|
|
* @param $attribute |
823
|
|
|
* @param $rule |
824
|
|
|
* @param $parameter |
825
|
|
|
* @return mixed |
826
|
|
|
*/ |
827
|
|
|
public function replaceIsmn($message, $attribute, $rule, $parameter) |
|
|
|
|
828
|
|
|
{ |
829
|
|
|
return $this->valueReplacer($message, $attribute); |
830
|
|
|
} |
831
|
|
|
|
832
|
|
|
/** |
833
|
|
|
* Replace all place-holders for the iswc rule |
834
|
|
|
* |
835
|
|
|
* @param $message |
836
|
|
|
* @param $attribute |
837
|
|
|
* @param $rule |
838
|
|
|
* @param $parameter |
839
|
|
|
* @return mixed |
840
|
|
|
*/ |
841
|
|
|
public function replaceIswc($message, $attribute, $rule, $parameter) |
|
|
|
|
842
|
|
|
{ |
843
|
|
|
return $this->valueReplacer($message, $attribute); |
844
|
|
|
} |
845
|
|
|
|
846
|
|
|
/** |
847
|
|
|
* Replace all place-holders for the mac rule |
848
|
|
|
* |
849
|
|
|
* @param $message |
850
|
|
|
* @param $attribute |
851
|
|
|
* @param $rule |
852
|
|
|
* @param $parameter |
853
|
|
|
* @return mixed |
854
|
|
|
*/ |
855
|
|
|
public function replaceMac($message, $attribute, $rule, $parameter) |
|
|
|
|
856
|
|
|
{ |
857
|
|
|
return $this->valueReplacer($message, $attribute); |
858
|
|
|
} |
859
|
|
|
|
860
|
|
|
/** |
861
|
|
|
* Replace all place-holders for the nif rule |
862
|
|
|
* |
863
|
|
|
* @param $message |
864
|
|
|
* @param $attribute |
865
|
|
|
* @param $rule |
866
|
|
|
* @param $parameter |
867
|
|
|
* @return mixed |
868
|
|
|
*/ |
869
|
|
|
public function replaceNif($message, $attribute, $rule, $parameter) |
|
|
|
|
870
|
|
|
{ |
871
|
|
|
return $this->valueReplacer($message, $attribute); |
872
|
|
|
} |
873
|
|
|
|
874
|
|
|
/** |
875
|
|
|
* Replace all place-holders for the organisme_type12_norme_b2 rule |
876
|
|
|
* |
877
|
|
|
* @param $message |
878
|
|
|
* @param $attribute |
879
|
|
|
* @param $rule |
880
|
|
|
* @param $parameter |
881
|
|
|
* @return mixed |
882
|
|
|
*/ |
883
|
|
|
public function replaceOrganismeType12NormeB2($message, $attribute, $rule, $parameter) |
|
|
|
|
884
|
|
|
{ |
885
|
|
|
return $this->valueReplacer($message, $attribute); |
886
|
|
|
} |
887
|
|
|
|
888
|
|
|
/** |
889
|
|
|
* Replace all place-holders for the phonenumber rule |
890
|
|
|
* |
891
|
|
|
* @param $message |
892
|
|
|
* @param $attribute |
893
|
|
|
* @param $rule |
894
|
|
|
* @param $parameter |
895
|
|
|
* @return mixed |
896
|
|
|
*/ |
897
|
|
|
protected function replacePhonenumber($message, $attribute, $rule, $parameter) |
|
|
|
|
898
|
|
|
{ |
899
|
|
|
$message = $this->valueReplacer($message, $attribute); |
900
|
|
|
$message = $this->countryReplacer($message, $parameter); |
901
|
|
|
|
902
|
|
|
return $message; |
903
|
|
|
} |
904
|
|
|
|
905
|
|
|
/** |
906
|
|
|
* Replace all place-holders for the sedol rule |
907
|
|
|
* |
908
|
|
|
* @param $message |
909
|
|
|
* @param $attribute |
910
|
|
|
* @param $rule |
911
|
|
|
* @param $parameter |
912
|
|
|
* @return mixed |
913
|
|
|
*/ |
914
|
|
|
public function replaceSedol($message, $attribute, $rule, $parameter) |
|
|
|
|
915
|
|
|
{ |
916
|
|
|
return $this->valueReplacer($message, $attribute); |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
/** |
920
|
|
|
* Replace all place-holders for the siren rule |
921
|
|
|
* |
922
|
|
|
* @param $message |
923
|
|
|
* @param $attribute |
924
|
|
|
* @param $rule |
925
|
|
|
* @param $parameter |
926
|
|
|
* @return mixed |
927
|
|
|
*/ |
928
|
|
|
public function replaceSiren($message, $attribute, $rule, $parameter) |
|
|
|
|
929
|
|
|
{ |
930
|
|
|
return $this->valueReplacer($message, $attribute); |
931
|
|
|
} |
932
|
|
|
|
933
|
|
|
/** |
934
|
|
|
* Replace all place-holders for the siret rule |
935
|
|
|
* |
936
|
|
|
* @param $message |
937
|
|
|
* @param $attribute |
938
|
|
|
* @param $rule |
939
|
|
|
* @param $parameter |
940
|
|
|
* @return mixed |
941
|
|
|
*/ |
942
|
|
|
public function replaceSiret($message, $attribute, $rule, $parameter) |
|
|
|
|
943
|
|
|
{ |
944
|
|
|
return $this->valueReplacer($message, $attribute); |
945
|
|
|
} |
946
|
|
|
|
947
|
|
|
/** |
948
|
|
|
* Replace all place-holders for the sscc rule |
949
|
|
|
* |
950
|
|
|
* @param $message |
951
|
|
|
* @param $attribute |
952
|
|
|
* @param $rule |
953
|
|
|
* @param $parameter |
954
|
|
|
* @return mixed |
955
|
|
|
*/ |
956
|
|
|
public function replaceSscc($message, $attribute, $rule, $parameter) |
|
|
|
|
957
|
|
|
{ |
958
|
|
|
return $this->valueReplacer($message, $attribute); |
959
|
|
|
} |
960
|
|
|
|
961
|
|
|
/** |
962
|
|
|
* Replace all place-holders for the ssn rule |
963
|
|
|
* |
964
|
|
|
* @param $message |
965
|
|
|
* @param $attribute |
966
|
|
|
* @param $rule |
967
|
|
|
* @param $parameter |
968
|
|
|
* @return mixed |
969
|
|
|
*/ |
970
|
|
|
public function replaceSSn($message, $attribute, $rule, $parameter) |
|
|
|
|
971
|
|
|
{ |
972
|
|
|
return $this->valueReplacer($message, $attribute); |
973
|
|
|
} |
974
|
|
|
|
975
|
|
|
/** |
976
|
|
|
* Replace all place-holders for the structured_communication rule |
977
|
|
|
* |
978
|
|
|
* @param $message |
979
|
|
|
* @param $attribute |
980
|
|
|
* @param $rule |
981
|
|
|
* @param $parameter |
982
|
|
|
* @return mixed |
983
|
|
|
*/ |
984
|
|
|
public function replaceStructuredCommunication($message, $attribute, $rule, $parameter) |
|
|
|
|
985
|
|
|
{ |
986
|
|
|
return $this->valueReplacer($message, $attribute); |
987
|
|
|
} |
988
|
|
|
|
989
|
|
|
/** |
990
|
|
|
* Replace all place-holders for the swift_bic rule |
991
|
|
|
* |
992
|
|
|
* @param $message |
993
|
|
|
* @param $attribute |
994
|
|
|
* @param $rule |
995
|
|
|
* @param $parameter |
996
|
|
|
* @return mixed |
997
|
|
|
*/ |
998
|
|
|
public function replaceSwiftBic($message, $attribute, $rule, $parameter) |
|
|
|
|
999
|
|
|
{ |
1000
|
|
|
return $this->valueReplacer($message, $attribute); |
1001
|
|
|
} |
1002
|
|
|
|
1003
|
|
|
/** |
1004
|
|
|
* Replace all place-holders for the udi rule |
1005
|
|
|
* |
1006
|
|
|
* @param $message |
1007
|
|
|
* @param $attribute |
1008
|
|
|
* @param $rule |
1009
|
|
|
* @param $parameter |
1010
|
|
|
* @return mixed |
1011
|
|
|
*/ |
1012
|
|
|
public function replaceUdi($message, $attribute, $rule, $parameter) |
|
|
|
|
1013
|
|
|
{ |
1014
|
|
|
return $this->valueReplacer($message, $attribute); |
1015
|
|
|
} |
1016
|
|
|
|
1017
|
|
|
/** |
1018
|
|
|
* Replace all place-holders for the uknin rule |
1019
|
|
|
* |
1020
|
|
|
* @param $message |
1021
|
|
|
* @param $attribute |
1022
|
|
|
* @param $rule |
1023
|
|
|
* @param $parameter |
1024
|
|
|
* @return mixed |
1025
|
|
|
*/ |
1026
|
|
|
public function replaceUknin($message, $attribute, $rule, $parameter) |
|
|
|
|
1027
|
|
|
{ |
1028
|
|
|
return $this->valueReplacer($message, $attribute); |
1029
|
|
|
} |
1030
|
|
|
|
1031
|
|
|
/** |
1032
|
|
|
* Replace all place-holders for the upca rule |
1033
|
|
|
* |
1034
|
|
|
* @param $message |
1035
|
|
|
* @param $attribute |
1036
|
|
|
* @param $rule |
1037
|
|
|
* @param $parameter |
1038
|
|
|
* @return mixed |
1039
|
|
|
*/ |
1040
|
|
|
public function replaceUpca($message, $attribute, $rule, $parameter) |
|
|
|
|
1041
|
|
|
{ |
1042
|
|
|
return $this->valueReplacer($message, $attribute); |
1043
|
|
|
} |
1044
|
|
|
|
1045
|
|
|
/** |
1046
|
|
|
* Replace all place-holders for the zipcode rule |
1047
|
|
|
* |
1048
|
|
|
* @param $message |
1049
|
|
|
* @param $attribute |
1050
|
|
|
* @param $rule |
1051
|
|
|
* @param $parameter |
1052
|
|
|
* @return mixed |
1053
|
|
|
*/ |
1054
|
|
|
public function replaceZipcode($message, $attribute, $rule, $parameter) |
|
|
|
|
1055
|
|
|
{ |
1056
|
|
|
$message = $this->valueReplacer($message, $attribute); |
1057
|
|
|
$message = $this->countryReplacer($message, $parameter); |
1058
|
|
|
|
1059
|
|
|
return $message; |
1060
|
|
|
} |
1061
|
|
|
} |
1062
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.