Skip to content

Commit

Permalink
Use early return when repsonse is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ah-net committed Jan 16, 2025
1 parent 4356dda commit 63da07c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Model/Config/Source/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ protected function buildOptions()
['value' => null, 'label' => __('* Default template')],
];

if (!empty($response->getTemplates())) {
foreach ($response->getTemplates() as $template) {
$result[] = ['value' => $template->getTemplateId(), 'label' => $template->getName()];
}
if (!is_array($response->getTemplates())) {
return $result;
}

foreach ($response->getTemplates() as $template) {
$result[] = ['value' => $template->getTemplateId(), 'label' => $template->getName()];
}

return $result;
Expand Down

0 comments on commit 63da07c

Please sign in to comment.