MaxConstraintValidator   A
last analyzed

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 6
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 8 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\NotBlank;
13
use Symfony\Component\Validator\Constraints\Positive;
14
use Symfony\Component\Validator\Constraints\Type;
15
use Symfony\Component\Validator\ConstraintViolationListInterface;
16
use Symfony\Component\Validator\Validation;
17
18
/**
19
 * @Annotation
20
 */
21
class MaxConstraintValidator
22
{
23
    /**
24
     * @param int $max
25
     */
26 55
    public function validate($max): ConstraintViolationListInterface
27
    {
28 55
        $validator = Validation::createValidator();
29
30 55
        return $validator->validate($max, [
31 55
            new NotBlank(),
32 55
            new Type('numeric'),
33 55
            new Positive(),
34
        ]);
35
    }
36
}
37