@@ -17,16 +17,14 @@ abstract protected function min(): int;
17
17
/** The maximum allowed value. */
18
18
abstract protected function max (): int ;
19
19
20
- public ?string $ description = 'Checks if the given column is of the format 96-well column ' ;
21
-
22
20
public function serialize ($ value )
23
21
{
24
22
if (is_int ($ value ) && $ this ->isValueInExpectedRange ($ value )) {
25
23
return $ value ;
26
24
}
27
25
28
26
$ notInRange = Utils::printSafe ($ value );
29
- throw new \InvalidArgumentException ("Value not in range: {$ notInRange }. " );
27
+ throw new \InvalidArgumentException ("Value not in range { $ this -> rangeDescription ()} : {$ notInRange }. " );
30
28
}
31
29
32
30
public function parseValue ($ value )
@@ -36,7 +34,7 @@ public function parseValue($value)
36
34
}
37
35
38
36
$ notInRange = Utils::printSafe ($ value );
39
- throw new Error ("Value not in range: {$ notInRange }. " );
37
+ throw new Error ("Value not in range { $ this -> rangeDescription ()} : {$ notInRange }. " );
40
38
}
41
39
42
40
public function parseLiteral (Node $ valueNode , ?array $ variables = null )
@@ -49,11 +47,19 @@ public function parseLiteral(Node $valueNode, ?array $variables = null)
49
47
}
50
48
51
49
$ notInRange = Printer::doPrint ($ valueNode );
52
- throw new Error ("Value not in range: {$ notInRange }. " , $ valueNode );
50
+ throw new Error ("Value not in range { $ this -> rangeDescription ()} : {$ notInRange }. " , $ valueNode );
53
51
}
54
52
55
53
private function isValueInExpectedRange (int $ value ): bool
56
54
{
57
55
return $ value <= static ::max () && $ value >= static ::min ();
58
56
}
57
+
58
+ private function rangeDescription (): string
59
+ {
60
+ $ min = static ::min ();
61
+ $ max = static ::max ();
62
+
63
+ return "{$ min }- {$ max }" ;
64
+ }
59
65
}
0 commit comments