RegexpValidation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 7 2
1
<?php
2
3
namespace ntentan\utils\validator\validations;
4
use ntentan\utils\validator\Validation;
5
6
/**
7
 * Validates a field with a regular expression.
8
 *
9
 * @package ntentan\utils\validator\validations
10
 */
11
class RegexpValidation extends Validation
12
{
13 2
    public function run($field, $data)
14
    {
15 2
        $value = $this->getFieldValue($field, $data);
16 2
        return $this->evaluateResult(
17 2
            $field,
18 2
            preg_match_all(is_string($field['options']) ? $field['options'] : $field['options'][0], $value) > 0,
19 2
            "The format of your input is invalid"
20 2
        );       
21
    }
22
}