3 namespace Friendica\Core\Config\Util;
6 * Util class to help to convert from/to (p)config values
11 * Formats a DB value to a config value
12 * - null = The db-value isn't set
13 * - bool = The db-value is either '0' or '1'
14 * - array = The db-value is a serialized array
15 * - string = The db-value is a string
17 * Keep in mind that there aren't any numeric/integer config values in the database
19 * @param string|null $value
21 * @return null|array|string
23 public static function toConfigValue(?string $value)
31 case preg_match("|^a:[0-9]+:{.*}$|s", $value):
32 return unserialize($value);
40 * Formats a config value to a DB value (string)
46 public static function toDbValue($value): string
48 // if not set, save an empty string
55 case is_array($value):
56 return serialize($value);
59 return (string)$value;