MetaWidget   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 2
c 3
b 0
f 1
lcom 1
cbo 3
dl 0
loc 40
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 34 2
1
<?php
2
/**
3
 * @link http://www.writesdown.com/
4
 * @copyright Copyright (c) 2015 WritesDown
5
 * @license http://www.writesdown.com/license/
6
 */
7
8
namespace widgets\meta;
9
10
use common\components\BaseWidget;
11
use Yii;
12
use yii\widgets\Menu;
13
14
/**
15
 * Class MetaWidget
16
 *
17
 * @author Agiel K. Saputra <[email protected]>
18
 * @since 0.1.1
19
 */
20
class MetaWidget extends BaseWidget
21
{
22
    /**
23
     * @inheritdoc
24
     */
25
    public function run()
26
    {
27
        echo $this->beforeWidget;
28
29
        if ($this->title) {
30
            echo $this->beforeTitle . $this->title . $this->afterTitle;
31
        }
32
33
        echo Menu::widget([
34
            'items' => [
35
                [
36
                    'label' => 'Site Admin',
37
                    'url' => Yii::$app->urlManagerBack->baseUrl,
38
                    'visible' => !Yii::$app->user->isGuest,
39
                ],
40
                [
41
                    'label' => 'Login',
42
                    'url' => Yii::$app->urlManagerBack->createUrl(['/site/login']),
43
                    'visible' => Yii::$app->user->isGuest,
44
                ],
45
                [
46
                    'label' => 'Logout',
47
                    'url' => Yii::$app->urlManager->createUrl(['/site/logout']),
48
                    'visible' => !Yii::$app->user->isGuest,
49
                    'template' => '<a href="{url}" data-method="post">{label}</a>',
50
                ],
51
                [
52
                    'label' => 'WritesDown.com',
53
                    'url' => 'http://www.writesdown.com/',
54
                ],
55
            ],
56
        ]);
57
        echo $this->afterWidget;
58
    }
59
}
60