Dashlet: Add return type decleration where applicable & use parent method in toArray()

This commit is contained in:
Yonas Habteab 2022-06-13 09:29:55 +02:00
parent 92226d4f08
commit d0b3437995

View File

@ -79,7 +79,7 @@ class Dashlet extends BaseDashboard
* *
* @return ?Url * @return ?Url
*/ */
public function getUrl() public function getUrl(): ?Url
{ {
if ($this->url !== null && ! $this->url instanceof Url) { if ($this->url !== null && ! $this->url instanceof Url) {
if (! Icinga::app()->isCli()) { if (! Icinga::app()->isCli()) {
@ -151,7 +151,7 @@ class Dashlet extends BaseDashboard
* *
* @return ?Pane * @return ?Pane
*/ */
public function getPane() public function getPane(): ?Pane
{ {
return $this->pane; return $this->pane;
} }
@ -161,7 +161,7 @@ class Dashlet extends BaseDashboard
* *
* @return ?string * @return ?string
*/ */
public function getModule() public function getModule(): ?string
{ {
return $this->module; return $this->module;
} }
@ -250,15 +250,11 @@ class Dashlet extends BaseDashboard
public function toArray(bool $stringify = true): array public function toArray(bool $stringify = true): array
{ {
$arr = parent::toArray($stringify);
$pane = $this->getPane(); $pane = $this->getPane();
return [ $arr['pane'] = ! $stringify ? $pane : ($pane ? $pane->getName() : null);
'id' => $this->getUuid(), $arr['url'] = $this->getUrl()->getRelativeUrl();
'pane' => ! $stringify ? $pane : ($pane ? $pane->getName() : null),
'name' => $this->getName(), return $arr;
'url' => $this->getUrl()->getRelativeUrl(),
'label' => $this->getTitle(),
'priority' => $this->getPriority(),
'description' => $this->getDescription()
];
} }
} }