Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
NotEmpty
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 validate
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
 getInverseError
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Verja\Validator;
4
5use Verja\Error;
6use Verja\Validator;
7
8class NotEmpty extends Validator
9{
10    /** {@inheritdoc} */
11    public function validate($value, array $context = []): bool
12    {
13        if (empty($value)) {
14            $this->error = new Error(
15                'IS_EMPTY',
16                $value,
17                'value should not be empty'
18            );
19            return false;
20        }
21
22        return true;
23    }
24
25    /** {@inheritdoc} */
26    public function getInverseError($value)
27    {
28        return new Error(
29            'NOT_EMPTY',
30            $value,
31            'value should be empty'
32        );
33    }
34}