Conditions | 2 |
Paths | 2 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 2 | public function create(SymfonyConstraint $constraint): Constraint |
|
18 | { |
||
19 | /** @var Assert\Length $constraint */ |
||
20 | |||
21 | $options = [ |
||
22 | 2 | 'min' => $constraint->min, |
|
23 | 2 | 'max' => $constraint->max, |
|
24 | 2 | 'message' => $this->trans( |
|
25 | 2 | 'This value should have {{ min }} to {{ max }} characters.', |
|
26 | 2 | ['{{ min }}' => $constraint->min, '{{ max }}' => $constraint->max] |
|
27 | ), |
||
28 | ]; |
||
29 | |||
30 | 2 | if ($constraint->min === $constraint->max) { |
|
31 | 1 | $options['message'] = $this->transChoice( |
|
32 | 1 | $constraint->exactMessage, |
|
33 | 1 | (int) $constraint->min, |
|
34 | 1 | ['{{ limit }}' => $constraint->min] |
|
35 | ); |
||
36 | } |
||
37 | |||
38 | 2 | return new ParsleyAssert\Length($options); |
|
39 | } |
||
49 |