Completed
Push — master ( 897cdb...04ceba )
by Andrii
03:04
created

CommandAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 25
ccs 0
cts 17
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 6 1
A getCommand() 0 8 2
A setCommand() 0 4 1
1
<?php
2
/**
3
 * HiAPI Yii2 base project for building API
4
 *
5
 * @link      https://github.com/hiqdev/hiapi
6
 * @package   hiapi
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiapi\controllers;
12
13
use Yii;
14
use yii\helpers\Inflector;
15
16
class CommandAction extends \yii\base\Action
17
{
18
    protected $_command;
19
20
    public function run()
21
    {
22
        var_dump($this->getCommand());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($this->getCommand()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
23
        die;
0 ignored issues
show
Coding Style Compatibility introduced by
The method run() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
24
        return Yii::$app->get('commandBus')->handle($this->getCommand());
0 ignored issues
show
Unused Code introduced by
return \Yii::$app->get('...e($this->getCommand()); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
25
    }
26
27
    public function getCommand()
28
    {
29
        if (!is_object($this->_command)) {
30
            $this->_command = Yii::createObject($this->_command);
31
        }
32
33
        return $this->_command;
34
    }
35
36
    public function setCommand($value)
37
    {
38
        $this->_command = $value;
39
    }
40
}
41