Skip to content

Commit

Permalink
Helper::set: Use match expression to determine value type
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin René Back committed May 19, 2021
1 parent 28cf4f4 commit 3043fe7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions pixelcatproductions/class/crisp/api/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,12 @@ public static function set(string $Key, mixed $Value): bool
Config::create($Key, $Value);
}

$Type = gettype($Value);
$Type = match($Value){
null => "NULL",
(is_array($Value) || is_object($Value)),Helper::isSerialized($Value) => "serialized",
default => gettype($Value)
};

if (Helper::isSerialized($Value)) {
$Type = "serialized";
}

if (is_array($Value) || is_object($Value)) {
$Type = "serialized";
$Value = serialize($Value);
}
if ($Type == "boolean") {
$Value = ($Value ? 1 : 0);
}
Expand Down

0 comments on commit 3043fe7

Please sign in to comment.