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