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

MaxConstraintValidator::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\NotBlank;
6
use Symfony\Component\Validator\Constraints\Positive;
7
use Symfony\Component\Validator\ConstraintViolationListInterface;
8
use Symfony\Component\Validator\Validation;
9
10
/**
11
 * @Annotation
12
 */
13
class MaxConstraintValidator
14
{
15
    /**
16
     * @param mixed $max
17
     * @return ConstraintViolationListInterface
18
     */
19 9
    public function validate($max): ConstraintViolationListInterface
20
    {
21 9
        $validator = Validation::createValidator();
22
23 9
        return $validator->validate($max, [
24 9
            new NotBlank(),
25 9
            new Positive(),
26
        ]);
27
    }
28
}
29