Conditions | 5 |
Paths | 3 |
Total Lines | 25 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
20 | public function run() |
||
21 | { |
||
22 | $model = new $this->modelClass; |
||
23 | |||
24 | if (($ids = Yii::$app->request->post('selection')) !== null) { |
||
25 | $models = $model::findAll($ids); |
||
26 | $operation = Yii::$app->request->post('operation'); |
||
27 | |||
28 | if (isset($this->operations[$operation])) { |
||
29 | $attrubutes = $this->operations[$operation]; |
||
30 | foreach ($models as $model) { |
||
31 | switch ($operation) { |
||
32 | case 'delete': |
||
33 | $model->delete(); |
||
34 | break; |
||
35 | default: |
||
36 | $model->updateAttributes($attrubutes); |
||
37 | break; |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 | } |
||
42 | |||
43 | return $this->controller->asJson(true); |
||
|
|||
44 | } |
||
45 | } |
||
46 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: