TicketActionsMenu::items()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 0
cts 15
cp 0
rs 9.7666
c 0
b 0
f 0
cc 4
nc 8
nop 0
crap 20
1
<?php
2
/**
3
 * HiPanel tickets module
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-ticket
6
 * @package   hipanel-module-ticket
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\ticket\menus;
12
13
use hipanel\modules\ticket\models\Thread;
14
use Yii;
15
16
class TicketActionsMenu extends \hiqdev\yii2\menus\Menu
17
{
18
    public $model;
19
20
    public function items()
21
    {
22
        return [
23
            [
24
                'label' => Yii::t('hipanel', 'View'),
25
                'icon' => 'fa-info',
26
                'url' => ['@ticket/view', 'id' => $this->model->id],
27
            ],
28
            [
29
                'label' => $this->model->state === Thread::STATE_OPEN ? Yii::t('hipanel:ticket', 'Close') : Yii::t('hipanel:ticket', 'Open'),
30
                'icon' => $this->model->state === Thread::STATE_OPEN ? 'fa-times' : 'fa-envelope-open-o',
31
                'url' => $this->model->state === Thread::STATE_OPEN ? ['@ticket/close', 'id' => $this->model->id] : ['@ticket/open', 'id' => $this->model->id],
32
            ],
33
        ];
34
    }
35
}
36