Completed
Branch develop (51c2e3)
by Anton
03:56 queued 01:52
created

Navigation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getSections() 0 6 2
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
9
namespace Spiral\Vault\Models;
10
11
use Spiral\Security\GuardInterface;
12
13
class Navigation
14
{
15
    /**
16
     * Guard is needed to show only allowed navigation sections and items.
17
     *
18
     * @var GuardInterface
19
     */
20
    private $guard = null;
21
22
    /**
23
     * Navigation sections list.
24
     *
25
     * @var array
26
     */
27
    private $sections = [];
28
29
    /**
30
     * Navigation constructor.
31
     *
32
     * @param GuardInterface $guard
33
     * @param array          $sections
34
     */
35
    public function __construct(GuardInterface $guard, array $sections)
36
    {
37
        $this->guard = $guard;
38
        $this->sections = $sections;
39
    }
40
41
    /**
42
     * Get all navigation sections. This is generator.
43
     *
44
     * @generator
45
     * @return \Generator
46
     */
47
    public function getSections(): \Generator
48
    {
49
        foreach ($this->sections as $section) {
50
            yield new Section($this->guard, $section);
51
        }
52
    }
53
}