Completed
Push — master ( 2a97e5...e0fa86 )
by Andrii
02:50
created

FeedbackForm::getDebugUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Health monitoring for Yii2 applications
4
 *
5
 * @link      https://github.com/hiqdev/yii2-monitoring
6
 * @package   yii2-monitoring
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\yii2\monitoring\models;
12
13
use hiqdev\yii2\monitoring\Module;
14
use Yii;
15
use yii\base\Model;
16
17
class FeedbackForm extends Model
18
{
19
    /**
20
     * @var string
21
     */
22
    public $message;
23
24
    /**
25
     * @var string
26
     */
27
    public $email;
28
29
    /**
30
     * @var string
31
     */
32
    public $session_tag;
33
34
    public function attributes()
35
    {
36
        return ['message', 'email', 'session_tag'];
37
    }
38
39
    public function attributeLabels()
40
    {
41
        return [
42
            'message' => Yii::t('monitoring', 'Message'),
43
        ];
44
    }
45
46
    public function rules()
47
    {
48
        return [
49
            [['message'], 'required'],
50
            [['email'], 'safe', 'when' => Yii::$app->user->isGuest],
51
            [['session_tag'], 'safe'],
52
        ];
53
    }
54
55
    public function getDebugUrl()
56
    {
57
        return $this->getModule()->getDebugUrl($this->session_tag);
58
    }
59
60
    public function getModule()
61
    {
62
        return Module::getInstance();
63
    }
64
}
65