@@ 17-32 (lines=16) @@ | ||
14 | * |
|
15 | * @author Karsten J. Gerber <[email protected]> |
|
16 | */ |
|
17 | class IsIntegerString extends AbstractUnaryFunction |
|
18 | { |
|
19 | /** |
|
20 | * @param mixed $input |
|
21 | * |
|
22 | * @return bool |
|
23 | */ |
|
24 | public function __invoke($input) |
|
25 | { |
|
26 | /** @noinspection TypeUnsafeComparisonInspection */ |
|
27 | return is_string($input) |
|
28 | && is_numeric($input) |
|
29 | && (((int) $input) == $input) // the non-type-safe comparison here is on purpose |
|
30 | ; |
|
31 | } |
|
32 | } |
|
33 |
@@ 16-31 (lines=16) @@ | ||
13 | * |
|
14 | * @author Karsten J. Gerber <[email protected]> |
|
15 | */ |
|
16 | class IsNumericString extends AbstractUnaryFunction |
|
17 | { |
|
18 | /** |
|
19 | * @param mixed $input |
|
20 | * |
|
21 | * @return bool |
|
22 | */ |
|
23 | public function __invoke($input) |
|
24 | { |
|
25 | /** @noinspection TypeUnsafeComparisonInspection */ |
|
26 | return is_string($input) |
|
27 | && is_numeric($input) |
|
28 | && (((double) $input) == $input) // the non-type-safe comparison here is on purpose |
|
29 | ; |
|
30 | } |
|
31 | } |
|
32 |