|
7 | 7 | use TypeLang\Mapper\Exception\Definition\Shape\ShapeFieldsNotSupportedException; |
8 | 8 | use TypeLang\Mapper\Exception\Definition\Template\Hint\TemplateArgumentHintsNotSupportedException; |
9 | 9 | use TypeLang\Mapper\Exception\Definition\Template\InvalidTemplateArgumentException; |
| 10 | +use TypeLang\Mapper\Exception\Definition\Template\OneOfTemplateArgumentsCountException; |
10 | 11 | use TypeLang\Mapper\Exception\Definition\Template\TooManyTemplateArgumentsInRangeException; |
11 | 12 | use TypeLang\Mapper\Type\IntRangeType; |
12 | 13 | use TypeLang\Mapper\Type\IntType; |
@@ -44,27 +45,14 @@ public function build( |
44 | 45 |
|
45 | 46 | return match (\count($arguments)) { |
46 | 47 | 0 => new IntType(), |
47 | | - 1 => $this->buildWithMinValue($statement, $arguments[0]), |
48 | 48 | 2 => $this->buildWithMinMaxValues($statement, $arguments[0], $arguments[1]), |
49 | | - default => throw TooManyTemplateArgumentsInRangeException::becauseArgumentsCountRequired( |
50 | | - minArgumentsCount: 0, |
51 | | - maxArgumentsCount: 2, |
| 49 | + default => throw OneOfTemplateArgumentsCountException::becauseArgumentsCountDoesNotMatch( |
| 50 | + variants: [0, 2], |
52 | 51 | type: $statement, |
53 | 52 | ), |
54 | 53 | }; |
55 | 54 | } |
56 | 55 |
|
57 | | - /** |
58 | | - * @throws InvalidTemplateArgumentException |
59 | | - * @throws TemplateArgumentHintsNotSupportedException |
60 | | - */ |
61 | | - private function buildWithMinValue(NamedTypeNode $statement, ArgNode $min): IntRangeType |
62 | | - { |
63 | | - $value = $this->fetchTemplateArgumentValue($statement, $min); |
64 | | - |
65 | | - return new IntRangeType($value); |
66 | | - } |
67 | | - |
68 | 56 | /** |
69 | 57 | * @throws InvalidTemplateArgumentException |
70 | 58 | * @throws TemplateArgumentHintsNotSupportedException |
|
0 commit comments