Macro: Fix typo and simplify the code

This commit is contained in:
Sukhwinder Dhillon 2024-03-25 14:27:46 +01:00 committed by Johannes Meyer
parent 41787d91bf
commit d6ceb9ad11
1 changed files with 8 additions and 3 deletions

View File

@ -62,7 +62,7 @@ class Macro
*/
public static function resolveMacro($macro, $object)
{
if (isset(self::$icingaMacros[$macro]) && isset($object->{self::$icingaMacros[$macro]})) {
if (isset(self::$icingaMacros[$macro], $object->{self::$icingaMacros[$macro]})) {
return $object->{self::$icingaMacros[$macro]};
}
@ -83,9 +83,14 @@ class Macro
}
$value = null;
Logger::debug('Unable to resolve macro "%s" on object "%s". An error occured: %s', $macro, $objectName, $e);
Logger::debug(
'Unable to resolve macro "%s" on object "%s". An error occurred: %s',
$macro,
$objectName,
$e
);
}
return $value !== null ? $value : $macro;
return $value ?? $macro;
}
}