Skip to content

Commit

Permalink
fix: errors after phpstan lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kolotov committed Sep 9, 2023
1 parent 1486418 commit f8f668f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function loadTexts(array $module): array
}

try {
$content = file_get_contents($textsFile);
$texts = $content ? json_decode($content, true, 512, JSON_THROW_ON_ERROR) : '';
$content = (string)file_get_contents($textsFile);
$texts = json_decode($content, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
}

$isEmptyConfig = !isset($texts) || !$texts;
$isEmptyConfig = !isset($texts) || $texts === '';
if ($isEmptyConfig) {
throw new RuntimeException("Config $textsFile wasn't loaded");
}
Expand All @@ -56,7 +56,8 @@ function buildGame(string $moduleName): array
}

require_once $moduleFile;
return "BrainGames\Games\\$moduleName\loader"($module);
$loader = "BrainGames\Games\\$moduleName\loader";
return is_callable($loader) ? $loader($module) : [];
}

function greetUser(array $module): array
Expand Down

0 comments on commit f8f668f

Please sign in to comment.