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