Skip to content

Commit e2642ed

Browse files
committed
Refactoring: use php 8 features
1 parent 78ae442 commit e2642ed

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/AbstractMenuItemsContainer.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,12 @@ private function hasVisibleItemsOn(string $type): bool
139139
private function getVisibleItemsOn(string $type): array
140140
{
141141
return array_filter($this->getItems(), function (IMenuItem $item) use ($type): bool {
142-
switch ($type) {
143-
case 'menu':
144-
return $item->isVisibleOnMenu();
145-
146-
case 'breadcrumbs':
147-
return $item->isVisibleOnBreadcrumbs();
148-
149-
case 'sitemap':
150-
return $item->isVisibleOnSitemap();
151-
152-
default:
153-
return false;
154-
}
142+
return match ($type) {
143+
'menu' => $item->isVisibleOnMenu(),
144+
'breadcrumbs' => $item->isVisibleOnBreadcrumbs(),
145+
'sitemap' => $item->isVisibleOnSitemap(),
146+
default => false,
147+
};
155148
});
156149
}
157150

src/MenuItem.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ public function isAllowed(): bool
8787

8888
public function getActionTarget(): ?string
8989
{
90-
return $this->action !== null
91-
? $this->action->target
92-
: null;
90+
return $this->action?->target;
9391
}
9492

9593
/**

0 commit comments

Comments
 (0)