RequiredValidation   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 a field contains a value.
8
 *
9
 * @package ntentan\utils\validator\validations
10
 */
11
class RequiredValidation extends Validation
12
{
13 4
    public function run($field, $data)
14
    {
15 4
        $value = $this->getFieldValue($field, $data);
16 4
        return $this->evaluateResult(
17 4
            $field, 
18 4
            $value !== null && $value !==  '', 
19 4
            "The {$field['name']} field is required"
20 4
        );        
21
    }
22
}