Completed
Push — master ( 7e75f8...53d3fb )
by Ryan
10:44 queued 05:05
created

NavigationSorter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A sort() 0 18 3
1
<?php namespace Anomaly\Streams\Platform\Ui\ControlPanel\Component\Navigation;
2
3
use Anomaly\Streams\Platform\Ui\ControlPanel\ControlPanelBuilder;
4
5
/**
6
 * Class NavigationSorter
7
 *
8
 * @link   http://pyrocms.com/
9
 * @author PyroCMS, Inc. <[email protected]>
10
 * @author Ryan Thompson <[email protected]>
11
 */
12
class NavigationSorter
13
{
14
15
    /**
16
     * Create a new NavigationSorter instance.
17
     *
18
     * @param ControlPanelBuilder $builder
19
     */
20
    public function sort(ControlPanelBuilder $builder)
21
    {
22
        $navigation = $builder->getNavigation();
23
24
        ksort($navigation);
25
26
        foreach ($navigation as $key => $module) {
27
28
            if ($key == 'dashboard') {
29
30
                $navigation = [$key => $module] + $navigation;
31
32
                break;
33
            }
34
        }
35
36
        $builder->setNavigation($navigation);
37
    }
38
}
39