Pin::isValid()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 14
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 20
rs 9.7998
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
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
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