| Conditions | 7 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 24 | public function register() |
|
| 27 | { |
||
| 28 | $this->app->resolving('validator', function ($factory, $app) { |
||
|
|
|||
| 29 | |||
| 30 | 21 | $x = new Validator(); |
|
| 31 | |||
| 32 | 21 | $factory->extend('phone', function ($attribute, $value, $parameters, $validator) use ($x) { |
|
| 33 | 21 | if (count($parameters) > 0) { |
|
| 34 | 15 | switch ($parameters[0]) { |
|
| 35 | 15 | case 'digits': |
|
| 36 | 3 | return $x->isDigits($value); |
|
| 37 | 12 | case 'e164': |
|
| 38 | 12 | case 'E164': |
|
| 39 | 6 | return $x->isE164($value); |
|
| 40 | 6 | case 'nanp': |
|
| 41 | 6 | case 'NANP': |
|
| 42 | 3 | return $x->isNANP($value); |
|
| 43 | 3 | default: |
|
| 44 | 3 | throw new Exception($parameters[0]." is not a supported phone validation type.", 1); |
|
| 45 | 3 | } |
|
| 46 | } else { |
||
| 47 | 6 | return $x->isPhone($value); |
|
| 48 | } |
||
| 49 | 21 | }, "Not a valid phone number"); |
|
| 50 | 24 | }); |
|
| 51 | 24 | } |
|
| 52 | } |
||
| 53 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.