Completed
Push — master ( 37098b...75747c )
by Klochok
04:23
created

ReminderController::prepareRefs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 8
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
3
namespace hipanel\modules\ticket\controllers;
4
5
use hipanel\actions\RedirectAction;
6
use hipanel\actions\SmartPerformAction;
7
use Yii;
8
9 View Code Duplication
class ReminderController extends \hipanel\base\CrudController
0 ignored issues
show
Duplication introduced by
This class 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...
10
{
11
    public function actions()
12
    {
13
        return [
14
            'create' => [
15
                'class' => SmartPerformAction::class,
16
                'scenario' => 'update',
17
                'success' => Yii::t('hipanel/ticket', 'Comment was updated'),
18
                'POST' => [
19
                    'save' => true,
20
                    'success' => [
21
                        'class' => RedirectAction::class,
22
                        'url' => function () {
23
                            $answer = Yii::$app->request->post('Answer');
24
25
                            return ['@ticket/view', 'id' => $answer['id']];
26
                        },
27
                    ],
28
                ],
29
            ],
30
        ];
31
    }
32
33
    /**
34
     * @return array
35
     */
36
    protected function prepareRefs()
37
    {
38
        return [
39
            'topic_data' => $this->getRefs('topic,ticket', 'hipanel/ticket'),
40
            'state_data' => $this->getClassRefs('state', 'hipanel/ticket'),
41
            'priority_data' => $this->getPriorities(),
0 ignored issues
show
Documentation Bug introduced by
The method getPriorities does not exist on object<hipanel\modules\t...ers\ReminderController>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
42
        ];
43
    }
44
}
45