required   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 12
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 5 3
1
<?php
2
3
namespace iamsaint\yml\validators;
4
5
use iamsaint\yml\BaseObject;
6
use iamsaint\yml\interfaces\Validator;
7
8
/**
9
 * Class required
10
 * @package iamsaint\yml\validators
11
 */
12
class required implements Validator
13
{
14
    /**
15
     * @param BaseObject $BaseObject
16
     * @param array $attributes
17
     * @param array $options
18
     */
19
    public function validate(BaseObject $BaseObject, array $attributes, array $options = []): void
20
    {
21
        foreach ($attributes as $attribute) {
22
            if (trim((string) $BaseObject->$attribute) === '') {
23
                $BaseObject->addError($attribute, $attribute.' cannot be empty');
24
            }
25
        }
26
    }
27
}
28