GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 7c9800...6d277d )
by Robert
25:06
created

Action::getUniqueId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\base;
9
10
use Yii;
11
12
/**
13
 * Action is the base class for all controller action classes.
14
 *
15
 * Action provides a way to reuse action method code. An action method in an Action
16
 * class can be used in multiple controllers or in different projects.
17
 *
18
 * Derived classes must implement a method named `run()`. This method
19
 * will be invoked by the controller when the action is requested.
20
 * The `run()` method can have parameters which will be filled up
21
 * with user input values automatically according to their names.
22
 * For example, if the `run()` method is declared as follows:
23
 *
24
 * ```php
25
 * public function run($id, $type = 'book') { ... }
26
 * ```
27
 *
28
 * And the parameters provided for the action are: `['id' => 1]`.
29
 * Then the `run()` method will be invoked as `run(1)` automatically.
30
 *
31
 * For more details and usage information on Action, see the [guide article on actions](guide:structure-controllers).
32
 *
33
 * @property string $uniqueId The unique ID of this action among the whole application. This property is
34
 * read-only.
35
 *
36
 * @author Qiang Xue <[email protected]>
37
 * @since 2.0
38
 */
39
class Action extends Component
40
{
41
    /**
42
     * @var string ID of the action
43
     */
44
    public $id;
45
    /**
46
     * @var Controller|\yii\web\Controller the controller that owns this action
47
     */
48
    public $controller;
49
50
51
    /**
52
     * Constructor.
53
     *
54
     * @param string $id the ID of this action
55
     * @param Controller $controller the controller that owns this action
56
     * @param array $config name-value pairs that will be used to initialize the object properties
57
     */
58 143
    public function __construct($id, $controller, $config = [])
59
    {
60 143
        $this->id = $id;
61 143
        $this->controller = $controller;
62 143
        parent::__construct($config);
63 143
    }
64
65
    /**
66
     * Returns the unique ID of this action among the whole application.
67
     *
68
     * @return string the unique ID of this action among the whole application.
69
     */
70 95
    public function getUniqueId()
71
    {
72 95
        return $this->controller->getUniqueId() . '/' . $this->id;
73
    }
74
75
    /**
76
     * Runs this action with the specified parameters.
77
     * This method is mainly invoked by the controller.
78
     *
79
     * @param array $params the parameters to be bound to the action's run() method.
80
     * @return mixed the result of the action
81
     * @throws InvalidConfigException if the action class does not have a run() method
82
     */
83 6
    public function runWithParams($params)
84
    {
85 6
        if (!method_exists($this, 'run')) {
86
            throw new InvalidConfigException(get_class($this) . ' must define a "run()" method.');
87
        }
88 6
        $args = $this->controller->bindActionParams($this, $params);
89 6
        Yii::trace('Running action: ' . get_class($this) . '::run()', __METHOD__);
90 6
        if (Yii::$app->requestedParams === null) {
91 6
            Yii::$app->requestedParams = $args;
92 6
        }
93 6
        if ($this->beforeRun()) {
94 6
            $result = call_user_func_array([$this, 'run'], $args);
95 6
            $this->afterRun();
96
97 6
            return $result;
98
        } else {
99
            return null;
100
        }
101
    }
102
103
    /**
104
     * This method is called right before `run()` is executed.
105
     * You may override this method to do preparation work for the action run.
106
     * If the method returns false, it will cancel the action.
107
     *
108
     * @return bool whether to run the action.
109
     */
110 6
    protected function beforeRun()
111
    {
112 6
        return true;
113
    }
114
115
    /**
116
     * This method is called right after `run()` is executed.
117
     * You may override this method to do post-processing work for the action run.
118
     */
119 6
    protected function afterRun()
120
    {
121 6
    }
122
}
123