From a09eba6b843804c33eeff7205b8a376d4e46724b Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 10 Aug 2020 16:59:06 +0200 Subject: [PATCH] Add type-safe wrapper around strtotime, removing ability for second param. --- MD_STD.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/MD_STD.php b/MD_STD.php index 61b99b2..9556f67 100644 --- a/MD_STD.php +++ b/MD_STD.php @@ -154,6 +154,21 @@ class MD_STD { } + /** + * Type-safe wrapper around strtotime(). + * + * @param string $datetime String to convert. + * + * @return integer + */ + public static function strtotime(string $datetime):int { + + $output = strtotime($datetime); + if ($output === false) throw new MDInvalidInputDate("Invalid input date {$datetime}."); + return $output; + + } + /** * Wrapper for curling contents from the web. *