olssonm /
identity-number
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Olssonm\IdentityNumber; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Static helper-class for accessing the validation methods statically |
||
| 7 | */ |
||
| 8 | class Pin |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Main method used for validation, acts as a static helper |
||
| 12 | * |
||
| 13 | * @param string $number the number |
||
| 14 | * @param string $type what type of validator to use |
||
| 15 | * @return boolean |
||
| 16 | */ |
||
| 17 | public static function isValid($number, $type = 'identity') |
||
| 18 | { |
||
| 19 | switch ($type) { |
||
| 20 | case 'identity': |
||
| 21 | $validator = new IdentityNumber(); |
||
| 22 | return $validator->isValid($number); |
||
| 23 | break; |
||
|
0 ignored issues
–
show
|
|||
| 24 | |||
| 25 | case 'organization': |
||
| 26 | $validator = new OrganizationNumber(); |
||
| 27 | return $validator->isValid($number); |
||
| 28 | break; |
||
| 29 | |||
| 30 | case 'coordination': |
||
| 31 | $validator = new CoordinationNumber(); |
||
| 32 | return $validator->isValid($number); |
||
| 33 | break; |
||
| 34 | } |
||
| 35 | |||
| 36 | return false; |
||
| 37 | } |
||
| 38 | } |
||
| 39 |
The
breakstatement is not necessary if it is preceded for example by areturnstatement:If you would like to keep this construct to be consistent with other
casestatements, you can safely mark this issue as a false-positive.