Conditions | 8 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
1 | <?php |
||
18 | public function isValid() |
||
19 | { |
||
20 | if ($this->isNotRequiredAndEmpty()) { |
||
21 | return true; |
||
22 | } |
||
23 | |||
24 | $phone = trim($this->getParams()[1]); |
||
25 | $phoneMask = substr($this->getParams()[2], 1, -1); |
||
26 | |||
27 | if (strlen($phone) != strlen($phoneMask)) { |
||
28 | return false; |
||
29 | } |
||
30 | |||
31 | foreach (str_split($phoneMask) as $index => $maskChar) { |
||
32 | if ($maskChar != '#' && $maskChar != $phone[$index]) { |
||
33 | return false; |
||
34 | } |
||
35 | |||
36 | if ($maskChar == '#' && !is_numeric($phone[$index])) { |
||
37 | return false; |
||
38 | } |
||
39 | } |
||
40 | |||
41 | return true; |
||
42 | } |
||
43 | |||
49 |