Completed
Push — master ( 602e72...ebe83b )
by James Ekow Abaka
01:26
created

NumericValidation::run()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 6
nc 1
nop 2
crap 2
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 1
            $field,
13 1
            is_numeric($value) || $value === null, 
14 1
            "The {$field['name']} field must contain only numbers"
15
        );     
16
    }
17
}