From e241bc1034ae16bf867ecc9f2b8a01654ebb21fd Mon Sep 17 00:00:00 2001 From: Danny van Wijk Date: Thu, 10 Oct 2024 12:21:22 +0200 Subject: [PATCH] Remove unnecessary count calls --- src/Kunstmaan/NodeBundle/Helper/NodeMenu.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Kunstmaan/NodeBundle/Helper/NodeMenu.php b/src/Kunstmaan/NodeBundle/Helper/NodeMenu.php index df997c82b8..5c536a53d1 100644 --- a/src/Kunstmaan/NodeBundle/Helper/NodeMenu.php +++ b/src/Kunstmaan/NodeBundle/Helper/NodeMenu.php @@ -277,8 +277,9 @@ public function getBreadCrumb() public function getCurrent() { $breadCrumb = $this->getBreadCrumb(); - if (\count($breadCrumb) > 0) { - return $breadCrumb[\count($breadCrumb) - 1]; + $totalBreadCrumbs = \count($breadCrumb); + if ($totalBreadCrumbs > 0) { + return $breadCrumb[$totalBreadCrumbs - 1]; } return null; @@ -398,12 +399,10 @@ public function getNextSibling(Node $node, $includeHiddenFromNav = true) if (false !== $parent = $this->getParent($node)) { $siblings = $this->getChildren($parent, $includeHiddenFromNav); + $totalSiblings = \count($siblings); foreach ($siblings as $index => $child) { - if ($child->getNode() === $node && (($index + 1) < \count( - $siblings - )) - ) { + if ($child->getNode() === $node && (($index + 1) < $totalSiblings)) { return $siblings[$index + 1]; } }