From 30bc68e6e2d642ec1a8258de377d46782825f616 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 16:48:22 +0400 Subject: Added integer parser Signed-off-by: Valentin Popov --- src/Parsers/IntegerParser.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Parsers/IntegerParser.php (limited to 'src/Parsers/IntegerParser.php') diff --git a/src/Parsers/IntegerParser.php b/src/Parsers/IntegerParser.php new file mode 100644 index 0000000..95df2dd --- /dev/null +++ b/src/Parsers/IntegerParser.php @@ -0,0 +1,36 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Parsers + */ +final class IntegerParser { + /** + * @param mixed $value + * + * @return int|null + */ + public static function get($value): ?int { + return filter_var($value, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE); + } +} -- cgit v1.2.3