Filled   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 8 2
A getMetadata() 0 5 1
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Validator;
4
5
use Formularium\Datatype;
6
use Formularium\Exception\ValidatorException;
7
use Formularium\Model;
8
use Formularium\ValidatorInterface;
9
use Formularium\Metadata;
10
11
/**
12
 * May not be present, but if it is must not be empty.
13
 */
14
class Filled implements ValidatorInterface
15
{
16 3
    public static function validate($value, array $options = [], ?Model $model = null)
17
    {
18
        // must be filled?
19 3
        if (empty($value)) {
20 1
            throw new ValidatorException("Field  must be filled");
21
        }
22
23 3
        return $value;
24
    }
25
26 1
    public static function getMetadata(): Metadata
27
    {
28 1
        return new Metadata(
29 1
            'Filled',
30 1
            "Field may not be present, but if it is must not be empty."
31
        );
32
    }
33
}
34