AI code quality fixes

This commit is contained in:
Matej Bačo 2025-12-11 15:52:44 +01:00
parent d502ab0cd5
commit 52ccbfcdf7

View file

@ -32,8 +32,15 @@ class Screenshot extends Action
public function action(string $templateId, string $variables): void public function action(string $templateId, string $variables): void
{ {
$variables = \json_decode($variables, true); if (empty($variables)) {
if(!\is_array($variables)) { $variables = [];
} else {
$variables = \json_decode($variables, true);
if (!\is_array($variables)) {
throw new \Exception('Invalid JSON in --variables flag');
}
}
if ($variables === null) {
throw new \Exception('Invalid JSON in --variables flag'); throw new \Exception('Invalid JSON in --variables flag');
} }
@ -207,7 +214,7 @@ class Screenshot extends Action
$value = \str_replace('{projectId}', $projectId, $value); $value = \str_replace('{projectId}', $projectId, $value);
$value = \str_replace('{apiEndpoint}', 'http://' . System::getEnv('_APP_DOMAIN', '') . '/v1', $value); $value = \str_replace('{apiEndpoint}', 'http://' . System::getEnv('_APP_DOMAIN', '') . '/v1', $value);
if(\array_key_exists($name, $variables)) { if (\array_key_exists($name, $variables)) {
$value = $variables[$name]; $value = $variables[$name];
} }