MaskTrait::maskIsValidate()   A
last analyzed

Complexity

Conditions 6
Paths 5

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 6
eloc 11
c 1
b 1
f 0
nc 5
nop 2
dl 0
loc 17
rs 9.2222
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
}