Skip to content

Instantly share code, notes, and snippets.

@dypsilon
Created June 5, 2011 00:00
Show Gist options
  • Save dypsilon/1008509 to your computer and use it in GitHub Desktop.
Save dypsilon/1008509 to your computer and use it in GitHub Desktop.
Guard Clause
<?php
public function markActiveNode($navigation, $currentUrl)
{
if(empty($navigation['nodes']) or !is_array($navigation['nodes']) {
return $navigation;
}
foreach ($navigation['nodes'] as $node) {
$node['isActive'] = false;
if(!empty($node['url'])) {
if($node['isVisible']) {
$node['isActive'] = ($node['url'] === $currentUrl);
}
}
}
return $navigation;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment