Conditions | 3 |
Paths | 2 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
38 | 7 | public static function build(Type $type, ?Scope $scope, Description $description, Configuration $configuration): self |
|
39 | { |
||
40 | // 2 char more needed for the ": " when transforming to string |
||
41 | 7 | $subjectLength = strlen((string)$type) + strlen((string)$scope) + strlen((string)$description) + 2; |
|
42 | |||
43 | 7 | if ($subjectLength > $configuration->maxLengthSubject() || $subjectLength < $configuration->minLengthSubject()) { |
|
44 | 4 | $errorMessage = sprintf("Invalid length for subject: '%s'. Must be between %s and %s", |
|
45 | 4 | "{$type}{$scope}: {$description}", |
|
46 | 4 | $configuration->minLengthSubject(), |
|
47 | 4 | $configuration->maxLengthSubject() |
|
48 | ); |
||
49 | 4 | throw new InvalidArgumentException($errorMessage); |
|
50 | } |
||
51 | |||
52 | 3 | return new self($type, $scope, $description); |
|
53 | } |
||
54 | |||
59 | } |