summaryrefslogtreecommitdiffstats
path: root/library/Director/Data/Db/DbDataFormatter.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Director/Data/Db/DbDataFormatter.php')
-rw-r--r--library/Director/Data/Db/DbDataFormatter.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/library/Director/Data/Db/DbDataFormatter.php b/library/Director/Data/Db/DbDataFormatter.php
index d6e4eeb..91fc776 100644
--- a/library/Director/Data/Db/DbDataFormatter.php
+++ b/library/Director/Data/Db/DbDataFormatter.php
@@ -6,7 +6,7 @@ use InvalidArgumentException;
class DbDataFormatter
{
- public static function normalizeBoolean($value)
+ public static function normalizeBoolean($value): ?string
{
if ($value === 'y' || $value === '1' || $value === true || $value === 1) {
return 'y';
@@ -20,7 +20,19 @@ class DbDataFormatter
throw new InvalidArgumentException(sprintf(
'Got invalid boolean: %s',
- var_export($value, 1)
+ var_export($value, true)
));
}
+
+ public static function booleanForDbValue($value): ?bool
+ {
+ if ($value === 'y') {
+ return true;
+ }
+ if ($value === 'n') {
+ return false;
+ }
+
+ return $value; // let this fail elsewhere, if not null
+ }
}