Completed
Push — develop ( 0660be...71868c )
by Freddie
04:14
created

RequiredConstraintValidator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 13
ccs 5
cts 5
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 7 1
1
<?php
2
3
namespace FlexPHP\Schema\Validators\Constraints;
4
5
use Symfony\Component\Validator\Constraints\Choice;
6
use Symfony\Component\Validator\Constraints\NotNull;
7
use Symfony\Component\Validator\ConstraintViolationListInterface;
8
use Symfony\Component\Validator\Validation;
9
10
/**
11
 * @Annotation
12
 */
13
class RequiredConstraintValidator
14
{
15
    /**
16
     * @param mixed $bool
17
     * @return ConstraintViolationListInterface
18
     */
19 13
    public function validate($bool): ConstraintViolationListInterface
20
    {
21 13
        $validator = Validation::createValidator();
22
23 13
        return $validator->validate($bool, [
24 13
            new NotNull(),
25 13
            new Choice([true, false, 'true', 'false']),
26
        ]);
27
    }
28
}
29