Completed
Push — develop ( 1f2dbe...562875 )
by Freddie
03:44
created

BooleanConstraintValidator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 7 1
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of FlexPHP.
4
 *
5
 * (c) Freddie Gar <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace FlexPHP\Schema\Validators\Constraints;
11
12
use Symfony\Component\Validator\Constraints\Choice;
13
use Symfony\Component\Validator\Constraints\NotNull;
14
use Symfony\Component\Validator\ConstraintViolationListInterface;
15
use Symfony\Component\Validator\Validation;
16
17
/**
18
 * @Annotation
19
 */
20
class BooleanConstraintValidator
21
{
22
    /**
23
     * @param bool $bool
24
     */
25 39
    public function validate($bool): ConstraintViolationListInterface
26
    {
27 39
        $validator = Validation::createValidator();
28
29 39
        return $validator->validate($bool, [
30 39
            new NotNull(),
31 39
            new Choice([true, false, 'true', 'false']),
32
        ]);
33
    }
34
}
35