File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -34,13 +34,19 @@ public function __construct($value)
34
34
if (!is_int ($ value ) && !is_string ($ value )) {
35
35
throw new TypeError ('An integer should be given as a string or integer, ' .gettype ($ value ).' received. ' );
36
36
}
37
- $ this -> value = filter_var ($ value , FILTER_SANITIZE_NUMBER_INT );
37
+ $ parsedValue = filter_var ($ value , FILTER_SANITIZE_NUMBER_INT );
38
38
39
- if (is_string ( $ value ) && $ this -> value !== $ value ) {
39
+ if (false === $ parsedValue ) {
40
40
throw new TypeError (
41
- 'A non-integer string has been provided: " ' .$ value .'", should be something like " ' .$ this ->value .'". '
41
+ 'A non-integer string has been provided: " ' .$ value .'". '
42
+ );
43
+ } elseif (is_string ($ value ) && $ parsedValue !== $ value )) {
44
+ throw new TypeError (
45
+ 'A non-integer string has been provided: " ' .$ value .'", should be something like " ' .$ parsedValue .'". '
42
46
);
43
47
}
48
+
49
+ $ this ->value = $ parsedValue ;
44
50
}
45
51
46
52
/**
You can’t perform that action at this time.
0 commit comments