AdminMenu   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 11
c 2
b 1
f 0
dl 0
loc 51
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUser() 0 3 1
A run() 0 7 1
1
<?php
2
3
namespace Itstructure\AdminModule\widgets\menu;
4
5
use yii\base\Widget;
6
use Itstructure\AdminModule\interfaces\AdminMenuInterface;
7
8
/**
9
 * Class AdminMenu
10
 *
11
 * @property string $profileLink Link to user profile.
12
 * @property string $signOutLink Link to sign-out action.
13
 * @property string[] $userBody This array contain a key->value pairs where key - is link name and value is link
14
 * that will be rendered in "user-body" section of menu.
15
 * @property AdminMenuInterface $user User model.
16
 *
17
 * @package Itstructure\AdminModule\widgets
18
 *
19
 * @author Andrey Girnik <[email protected]>
20
 */
21
class AdminMenu extends Widget
22
{
23
    /**
24
     * Link to user profile.
25
     *
26
     * @var string
27
     */
28
    public $profileLink = '/profile';
29
30
    /**
31
     * Link to sign-out action.
32
     *
33
     * @var string
34
     */
35
    public $signOutLink = '/sign-out';
36
37
    /**
38
     * This array contain a key->value pairs where key - is link name and value is link
39
     * that will be rendered in "user-body" section of menu.
40
     *
41
     * @var string[]
42
     */
43
    public $userBody = [];
44
45
    /**
46
     * User model.
47
     *
48
     * @var AdminMenuInterface
49
     */
50
    private $user;
51
52
    /**
53
     * Setter for the User model.
54
     *
55
     * @param AdminMenuInterface $user
56
     */
57
    public function setUser(AdminMenuInterface $user)
58
    {
59
        $this->user = $user;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function run()
66
    {
67
        return $this->render('admin-menu', [
68
            'user'        => $this->user,
69
            'profileLink' => $this->profileLink,
70
            'signOutLink' => $this->signOutLink,
71
            'userBody'    => $this->userBody,
72
        ]);
73
    }
74
}
75