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

Equal::isValid()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 3
nop 2
crap 3
1
<?php
2
namespace WebStream\Annotation\Attributes\Ext\ValidateRule;
3
4
/**
5
 * Equal
6
 * @author Ryuichi TANAKA.
7
 * @since 2015/03/30
8
 * @version 0.4
9
 */
10
class Equal implements IValidate
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 8
    public function isValid($value, $rule)
16
    {
17 8
        $isValid = false;
18 8
        if (preg_match('/^equal\[(.+)\]$/', $rule, $matches)) {
19 8
            $isValid = $value === null || $value === $matches[1];
20
        }
21
22 8
        return $isValid;
23
    }
24
}
25