MaskTrait   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 12
c 1
b 1
f 0
dl 0
loc 20
rs 10
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A maskIsValidate() 0 17 6
1
<?php
2
3
namespace Validate\Traits;
4
5
/**
6
 * Undocumented trait
7
 */
8
trait MaskTrait
9
{
10
11
    public static function maskIsValidate($number, $mask)
12
    {
13
        $i = 0;
14
        $maskLen = strlen($mask);
15
        $numberLen = strlen($number);
16
        if ($maskLen !== $numberLen) {
17
            return false;
18
        }
19
        while($i < $maskLen) {
20
            if (strtoupper($mask[$i])!=='X' && strtoupper($mask[$i])!=='#') {
21
                if ($mask[$i]!==$number[$i]) {
22
                    return false;
23
                }
24
            }
25
            $i = $i + 1;
26
        }
27
        return true;
28
    }
29
30
}