Conditions | 3 |
Paths | 2 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
26 | 8 | public static function build(string $description, Configuration $configuration): self |
|
27 | { |
||
28 | 8 | $description = trim($description); |
|
29 | 8 | $descriptionLength = strlen($description); |
|
30 | |||
31 | 8 | if ($descriptionLength > $configuration->maxLengthDescription() || |
|
32 | 8 | $descriptionLength < $configuration->minLengthDescription() |
|
33 | ) { |
||
34 | 3 | $errorMessage = sprintf("Invalid length for description: '%s'. Must be between %s and %s", |
|
35 | 3 | $description, |
|
36 | 3 | $configuration->minLengthDescription(), |
|
37 | 3 | $configuration->maxLengthDescription() |
|
38 | ); |
||
39 | 3 | throw new InvalidArgumentException($errorMessage); |
|
40 | } |
||
41 | |||
42 | 5 | return new self($description); |
|
43 | } |
||
44 | |||
49 | } |