Passed
Push — master ( 59e1e1...c1229c )
by Ryuichi
03:02
created

Regexp   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

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