TicketSettings   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 68
ccs 0
cts 35
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 9 1
A attributeLabels() 0 8 1
A getFormData() 0 7 1
A setFormData() 0 11 1
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\models;
12
13
use hipanel\modules\client\models\Client;
14
use Yii;
15
16
/**
17
 * Class TicketSettings.
18
 */
19
class TicketSettings extends \hipanel\base\Model
20
{
21
    /**
22
     * @var
23
     */
24
    public $ticket_emails;
25
26
    /**
27
     * @var
28
     */
29
    public $send_message_text;
30
31
    /**
32
     * @var boolean
33
     */
34
    public $new_messages_first;
35
36
    /**
37
     * @return array
38
     */
39
    public function rules()
40
    {
41
        return [
42
            ['ticket_emails', 'string', 'max' => 128],
43
            ['ticket_emails', 'email'],
44
            ['send_message_text', 'boolean'],
45
            ['new_messages_first', 'boolean'],
46
        ];
47
    }
48
49
    /**
50
     * @return array
51
     */
52
    public function attributeLabels()
53
    {
54
        return [
55
            'ticket_emails'     => Yii::t('hipanel:ticket', 'Email for tickets'),
56
            'send_message_text' => Yii::t('hipanel:ticket', 'Send message text'),
57
            'new_messages_first' => Yii::t('hipanel:ticket', 'New messages first'),
58
        ];
59
    }
60
61
    /**
62
     * Get form data from API.
63
     */
64
    public function getFormData()
65
    {
66
        $data                    = Client::perform('get-class-values', ['class' => 'client,ticket_settings']);
67
        $this->ticket_emails     = $data['ticket_emails'];
68
        $this->send_message_text = $data['send_message_text'];
69
        $this->new_messages_first = $data['new_messages_first'];
70
    }
71
72
    /**
73
     * Set form data to API.
74
     */
75
    public function setFormData()
76
    {
77
        Client::perform('set-class-values', [
78
            'class' => 'client,ticket_settings',
79
            'values' => [
80
                'ticket_emails'     => $this->ticket_emails,
81
                'send_message_text' => $this->send_message_text,
82
                'new_messages_first' => $this->new_messages_first,
83
            ],
84
        ]);
85
    }
86
}
87