Completed
Push — master ( 39ca89...64a0db )
by James Ekow Abaka
03:49
created

NumericValidation::run()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
ccs 5
cts 6
cp 0.8333
rs 9.6666
cc 2
eloc 6
nc 1
nop 2
crap 2.0185
1
<?php
2
3
namespace ntentan\utils\validator\validations;
4
use ntentan\utils\validator\Validation;
5
6
class NumericValidation extends Validation
7
{
8 1
    public function run($field, $data)
9
    {
10 1
        $value = $this->getFieldValue($field, $data);        
11 1
        return $this->evaluateResult(
12
            $field,
13 1
            is_numeric($value) || $value === null, 
14 1
            "The {$field['name']} field must contain only numbers"
15
        );     
16
    }
17
}