Skip to content

Commit

Permalink
Better checks to ensure values are the correct type
Browse files Browse the repository at this point in the history
  • Loading branch information
Spirit55555 committed May 28, 2021
1 parent 7e40312 commit acc1c5a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/MinecraftJSONColors.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static function convertToLegacy($json, string $color_char = '§', bool $h
self::$color_char = $color_char;
self::$hex_colors = $hex_colors;

if (is_string($json)) {
if (!empty($json) && is_string($json)) {
$json = json_decode($json, true);

//Just return an empty string, if JSON was invalid.
Expand All @@ -101,7 +101,8 @@ public static function convertToLegacy($json, string $color_char = '§', bool $h
}
}

$legacy .= self::parseElement($json);
if (is_array($json))
$legacy .= self::parseElement($json);

//If nothing was parsed until here, it's an array of components.
if (empty($legacy) && is_array($json)) {
Expand Down

0 comments on commit acc1c5a

Please sign in to comment.