Passed
Push — master ( fb814c...01670e )
by Ryuichi
36:14 queued 34:17
created

Regexp   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 5
c 0
b 0
f 0
dl 0
loc 13
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 8 3
1
<?php
2
3
namespace WebStream\Annotation\Attributes\Ext\ValidateRule;
4
5
/**
6
 * Regexp
7
 * @author Ryuichi TANAKA.
8
 * @since 2015/04/01
9
 * @version 0.4
10
 */
11
class Regexp implements IValidate
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 8
    public function isValid($value, $rule)
17
    {
18 8
        $isValid = false;
19 8
        if (preg_match('/^regexp\[(\/.*?\/[a-z]*)\]$/', $rule, $matches)) {
20 8
            $isValid = $value === null || preg_match($matches[1], $value);
21
        }
22
23 8
        return $isValid;
24
    }
25
}
26