Completed
Push — master ( bc4fbc...2f5514 )
by Klochok
13:50
created

Thread   A

Complexity

Total Complexity 30

Size/Duplication

Total Lines 296
Duplicated Lines 3.72 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 30
c 0
b 0
f 0
lcom 0
cbo 6
dl 11
loc 296
ccs 0
cts 218
cp 0
rs 10

22 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 5 1
A beforeChange() 0 7 1
A attributes() 0 56 1
A behaviors() 11 11 1
A rules() 0 47 1
A attributeLabels() 0 17 1
A getClient() 0 4 1
A getClient_id() 0 4 1
A getSeller() 0 4 1
A getSeller_id() 0 4 1
A getThreadUrl() 0 4 1
A parseMessage() 0 7 1
A prepareSpentTime() 0 4 1
A prepareTopic() 0 4 2
A getWatchersLogin() 0 10 2
A xFormater() 0 12 2
A getAnswers() 0 5 1
A getResponsibleClientTypes() 0 4 1
A getAnswer() 0 8 3
A getMaxAnswerId() 0 8 2
A scenarioActions() 0 7 1
A canSetSpent() 0 8 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\behaviors\File;
14
use hipanel\helpers\Markdown;
15
use hipanel\modules\client\models\Client;
16
use phpDocumentor\Reflection\Types\Callable_;
17
use stdClass;
18
use Yii;
19
use yii\web\NotFoundHttpException;
20
21
/**
22
 * Class Ticket.
23
 */
24
class Thread extends \hipanel\base\Model
25
{
26
    use \hipanel\base\ModelTrait;
27
28
    public static $i18nDictionary = 'hipanel:ticket';
29
30
    const STATE_OPEN = 'opened';
31
    const STATE_CLOSE = 'closed';
32
33
    public $search_form;
34
35
    public function init()
36
    {
37
        $this->on(static::EVENT_BEFORE_INSERT, [$this, 'beforeChange']);
38
        $this->on(static::EVENT_BEFORE_UPDATE, [$this, 'beforeChange']);
39
    }
40
41
    public function beforeChange($event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
        $this->prepareSpentTime();
44
        $this->prepareTopic();
45
46
        return true;
47
    }
48
49
    /**
50
     * @return array
51
     */
52 View Code Duplication
    public function behaviors()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54
        return [
55
            [
56
                'class' => File::class,
57
                'attribute' => 'file',
58
                'targetAttribute' => 'file_ids',
59
                'scenarios' => ['create', 'answer'],
60
            ],
61
        ];
62
    }
63
64
    /**
65
     * @return array
66
     */
67
    public function attributes()
68
    {
69
        return [
70
            'id',
71
            'subject',
72
            'state',
73
            'state_label',
74
            'author_email',
75
            'author',
76
            'author_id',
77
            'responsible_id',
78
            'responsible_email',
79
            'author_seller',
80
            'author_seller_id',
81
            'recipient_id',
82
            'recipient',
83
            'recipient_seller',
84
            'recipient_seller_id',
85
            'replier_id',
86
            'replier',
87
            'replier_seller',
88
            'replier_name',
89
            'responsible',
90
            'priority',
91
            'priority_label',
92
            'spent', 'spent_hours',
93
            'answer_count',
94
            'status',
95
            'reply_time',
96
            'create_time',
97
            'a_reply_time',
98
            'elapsed',
99
            'topics',
100
            'topic',
101
            'watchers',
102
            'watcher',
103
            'add_tag_ids',
104
            'file_ids',
105
            'file',
106
            'message', // 'answer_message',
107
            'is_private',
108
109
            'anonym_name',
110
            'anonym_email',
111
            'anonym_seller',
112
113
            'lastanswer',
114
            'time',
115
            'add_watchers', 'del_watchers',
116
117
            'time_from',
118
            'time_till',
119
120
            'contact',
121
        ];
122
    }
123
124
    /**
125
     * {@inheritdoc}
126
     */
127
    public function rules()
128
    {
129
        $rules = [
130
            [['author_id', 'responsible_id'], 'integer'],
131
            [['subject', 'message'], 'required', 'on' => ['create']],
132
            [['id'], 'required', 'on' => ['answer', 'update-answer', 'open', 'close']],
133
            [
134
                [
135
                    'topics',
136
                    'state',
137
                    'priority',
138
                    'responsible',
139
                    'recipient_id',
140
                    'watchers',
141
                    'spent', 'spent_hours',
142
                    'file_ids',
143
                ],
144
                'safe',
145
                'on' => 'create',
146
            ],
147
            [
148
                [
149
                    'message',
150
                    'topics', 'state', 'priority',
151
                    'responsible', 'recipient_id',
152
                    'watchers', 'add_watchers', 'del_watchers',
153
                    'is_private',
154
                    'file_ids',
155
                    'spent', 'spent_hours',
156
                ],
157
                'safe',
158
                'on' => 'answer',
159
            ],
160
            [['state'], 'safe', 'on' => ['close', 'open']],
161
            // only client-side validation. Answer is actually possible without a message,
162
            // but does not make any sense.
163
            [['message'], 'required', 'on' => ['answer'], 'when' => function () {
164
                return false;
165
            }],
166
            [['id'], 'integer', 'on' => 'answer'],
167
            [['file'], 'file', 'maxFiles' => 5],
168
            [['lastanswer', 'create_time', 'recipient'], 'safe'],
169
            [['author', 'author_seller'], 'safe', 'when' => Yii::$app->user->can('support')],
170
        ];
171
172
        return $rules;
173
    }
174
175
    /**
176
     * {@inheritdoc}
177
     */
178
    public function attributeLabels()
179
    {
180
        return $this->mergeAttributeLabels([
181
            'author' => Yii::t('hipanel:ticket', 'Author'),
182
            'author_id' => Yii::t('hipanel:ticket', 'Author'),
183
            'recipient' => Yii::t('hipanel:ticket', 'Recipient'),
184
            'is_private' => Yii::t('hipanel:ticket', 'Make private'),
185
            'responsible' => Yii::t('hipanel:ticket', 'Assignee'),
186
            'responsible_id' => Yii::t('hipanel:ticket', 'Assignee'),
187
            'spent' => Yii::t('hipanel:ticket', 'Spent time'),
188
            'create_time' => Yii::t('hipanel:ticket', 'Created'),
189
            'a_reply_time' => Yii::t('hipanel:ticket', 'a_reply_time'),
190
            'file' => Yii::t('hipanel:ticket', 'Files'),
191
            'lastanswer' => Yii::t('hipanel:ticket', 'Last answer'),
192
            'author_seller' => Yii::t('hipanel:ticket', 'Seller'),
193
        ]);
194
    }
195
196
    public function getClient()
197
    {
198
        return $this->author;
0 ignored issues
show
Documentation introduced by
The property author does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
199
    }
200
201
    public function getClient_id()
202
    {
203
        return $this->author_id;
0 ignored issues
show
Documentation introduced by
The property author_id does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
204
    }
205
206
    public function getSeller()
207
    {
208
        return $this->author_seller;
0 ignored issues
show
Documentation introduced by
The property author_seller does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
209
    }
210
211
    public function getSeller_id()
212
    {
213
        return $this->author_seller_id;
0 ignored issues
show
Documentation introduced by
The property author_seller_id does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
214
    }
215
216
    public function getThreadUrl()
217
    {
218
        return ['@ticket/view', 'id' => $this->id];
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
219
    }
220
221
    public static function parseMessage($message)
222
    {
223
        $message = str_replace(["\n\r", "\r\r", "\r\n"], "\n", $message); // "\n\n",
224
        $message = Markdown::process($message);
225
226
        return $message;
227
    }
228
229
    public function prepareSpentTime()
230
    {
231
        list($this->spent_hours, $this->spent) = explode(':', $this->spent, 2);
0 ignored issues
show
Documentation introduced by
The property spent_hours does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property spent does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
232
    }
233
234
    public function prepareTopic()
235
    {
236
        $this->topics = is_array($this->topics) ? implode(',', $this->topics) : $this->topics;
0 ignored issues
show
Documentation introduced by
The property topics does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property topics does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
237
    }
238
239
    public function getWatchersLogin()
240
    {
241
        $results = [];
242
        foreach ((array)$this->watchers as $id => $watcher) {
243
            list($login, $email) = explode(' ', $watcher);
0 ignored issues
show
Unused Code introduced by
The assignment to $email is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
244
            $results[$id] = $login;
245
        }
246
247
        return $results;
248
    }
249
250
    public function xFormater(array $items)
251
    {
252
        $result = [];
253
        foreach ($items as $id => $label) {
254
            $object = new stdClass();
255
            $object->value = $id;
256
            $object->text = $label;
257
            $result[] = $object;
258
        }
259
260
        return $result;
261
    }
262
263
    public function getAnswers()
264
    {
265
        // TODO: redo API in order to have different `Thread` and `ThreadMessage` models
266
        return $this->hasMany(Answer::class, ['id' => 'id'])->joinWith('files')->indexBy('answer_id');
267
    }
268
269
    /**
270
     * Returns array of client types, that can be set as responsible for the thread.
271
     *
272
     * @return array
273
     */
274
    public static function getResponsibleClientTypes()
275
    {
276
        return [Client::TYPE_SELLER, Client::TYPE_ADMIN, Client::TYPE_MANAGER, Client::TYPE_OWNER];
277
    }
278
279
    /**
280
     * @param integer $id
281
     * @param bool $throwOnError whether to throw an exception when answer is not found in thread
282
     * @throws NotFoundHttpException
283
     * @return Answer
284
     */
285
    public function getAnswer($id, $throwOnError = true)
286
    {
287
        if (!isset($this->answers[$id]) && $throwOnError) {
0 ignored issues
show
Documentation introduced by
The property answers does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
288
            throw new NotFoundHttpException('Answer does not belong to this model');
289
        }
290
291
        return $this->answers[$id];
0 ignored issues
show
Documentation introduced by
The property answers does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
292
    }
293
294
    public function getMaxAnswerId()
295
    {
296
        if ($this->isRelationPopulated('answers')) {
297
            return max(array_keys($this->answers));
0 ignored issues
show
Documentation introduced by
The property answers does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
298
        }
299
300
        return $this->id;
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<hipanel\modules\ticket\models\Thread>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
301
    }
302
303
    public function scenarioActions()
304
    {
305
        return [
306
            'open' => 'answer',
307
            'close' => 'answer',
308
        ];
309
    }
310
311
    public function canSetSpent()
312
    {
313
        if (isset(Yii::$app->params['ticket.canSetSpent']) && is_callable(Yii::$app->params['ticket.canSetSpent'])) {
314
            return call_user_func(Yii::$app->params['ticket.canSetSpent'], $this);
315
        }
316
317
        return true;
318
    }
319
}
320