MatchesPattern::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
3
namespace kalanis\kw_rules\Rules;
4
5
6
use kalanis\kw_rules\Interfaces\IValidate;
7
use kalanis\kw_rules\Exceptions\RuleException;
8
9
10
/**
11
 * Class MatchesPattern
12
 * @package kalanis\kw_rules\Rules
13
 * Check if input matches pattern
14
 */
15
class MatchesPattern extends ARule
16
{
17 12
    public function validate(IValidate $entry): void
18
    {
19 12
        if (!boolval(preg_match(strval($this->againstValue), strval($entry->getValue())))) {
20 9
            throw new RuleException($this->errorText);
21
        }
22 3
    }
23
}
24