NumericValidation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
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
 * Ensures that a field contains only numbers.
8
 *
9
 * @package ntentan\utils\validator\validations
10
 */
11
class NumericValidation 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
            is_numeric($value) || $value === null, 
19 2
            "The {$field['name']} field must contain only numbers"
20 2
        );     
21
    }
22
}