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

RequiredValidation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 12
c 0
b 0
f 0
ccs 5
cts 6
cp 0.8333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 9 2
1
<?php
2
3
namespace ntentan\utils\validator\validations;
4
use ntentan\utils\validator\Validation;
5
6
class RequiredValidation extends Validation
7
{
8 2
    public function run($field, $data)
9
    {
10 2
        $value = $this->getFieldValue($field, $data);
11 2
        return $this->evaluateResult(
12
            $field, 
13 2
            $value !== null && $value !==  '', 
14 2
            "The {$field['name']} field is required"
15
        );        
16
    }
17
}