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

RequiredConstraintValidator::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 10
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