From 3df56694121466456b4480e1930b0604cdefe26a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 7 Nov 2023 10:20:37 +0100 Subject: [PATCH] Extract helper method parameter instead of ternary check --- .../src/Framework/Factories/NavigationDataFactory.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/framework/src/Framework/Factories/NavigationDataFactory.php b/packages/framework/src/Framework/Factories/NavigationDataFactory.php index 44dcf51b400..7f7d02b7342 100644 --- a/packages/framework/src/Framework/Factories/NavigationDataFactory.php +++ b/packages/framework/src/Framework/Factories/NavigationDataFactory.php @@ -162,7 +162,7 @@ private function searchForPriorityInSidebarConfig(): ?int /** @var array|array $config */ $config = Config::getArray('docs.sidebar_order', []); - return $this->parseNavigationPriorityConfig($config); + return $this->parseNavigationPriorityConfig($config, 'identifier'); } private function searchForPriorityInNavigationConfig(): ?int @@ -178,11 +178,9 @@ private function searchForPriorityInNavigationConfig(): ?int } /** @param array|array $config */ - private function parseNavigationPriorityConfig(array $config): ?int + private function parseNavigationPriorityConfig(array $config, string $pageKeyName = 'routeKey'): ?int { - $pageKey = $this->isInstanceOf(DocumentationPage::class) - ? $this->identifier // Required for backwards compatibility. - : $this->routeKey; + $pageKey = $this->{$pageKeyName}; // Check if the config entry is a flat array or a keyed array. if (! array_key_exists($pageKey, $config)) {