From 01d5c79feeda7ff41101c78a5d55b9b6cffacf6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sat, 24 May 2014 18:56:07 +0200 Subject: [PATCH] boolean parse method --- application/core/Utils/Formatter.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/application/core/Utils/Formatter.php b/application/core/Utils/Formatter.php index 2e28143e..313ae7b9 100644 --- a/application/core/Utils/Formatter.php +++ b/application/core/Utils/Formatter.php @@ -176,4 +176,18 @@ abstract class Formatter { } return 'OTH'; } + + /** + * Parse the given Value into a Bool + * + * @param mixed $value + * @return bool + */ + public static function parseBoolean($value) { + if (is_string($value)) { + $value = strtolower($value); + } + $bool = filter_var($value, FILTER_VALIDATE_BOOLEAN); + return $bool; + } }