Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class RangeFactory implements TranslatableFactoryInterface |
||
11 | { |
||
12 | use FactoryTrait; |
||
13 | |||
14 | /** |
||
15 | * @inheritdoc |
||
16 | */ |
||
17 | 1 | public function create(SymfonyConstraint $constraint): Constraint |
|
18 | { |
||
19 | /** @var Assert\Range $constraint */ |
||
20 | |||
21 | 1 | $options = []; |
|
22 | |||
23 | 1 | if (null !== $constraint->min) { |
|
24 | $options += [ |
||
25 | 1 | 'min' => $constraint->min, |
|
26 | 1 | 'minMessage' => $this->trans($constraint->minMessage, ['{{ limit }}' => $constraint->min]), |
|
27 | ]; |
||
28 | } |
||
29 | |||
30 | 1 | if (null !== $constraint->max) { |
|
31 | $options += [ |
||
32 | 1 | 'max' => $constraint->max, |
|
33 | 1 | 'maxMessage' => $this->trans($constraint->maxMessage, ['{{ limit }}' => $constraint->max]), |
|
34 | ]; |
||
35 | } |
||
36 | |||
37 | 1 | return new ParsleyAssert\Range($options); |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | */ |
||
43 | 1 | public function supports(SymfonyConstraint $constraint): bool |
|
46 | } |
||
47 | } |
||
48 |