Action::__call()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 10
rs 10
cc 3
nc 3
nop 2
1
<?php
2
3
4
namespace carono\yii2crud\actions;
5
6
7
use yii\helpers\StringHelper;
8
9
abstract class Action extends \yii\base\Action
10
{
11
    public $primaryKeyParam = 'id';
12
    public $layout;
13
    public $view;
14
    public $modelClass;
15
16
    public function init()
17
    {
18
        if ($this->layout) {
19
            $this->controller->layout = $this->layout;
20
        }
21
        parent::init();
22
    }
23
24
    public function __call($name, $params)
25
    {
26
        if (StringHelper::startsWith($name, 'getMessage')) {
27
            $property = $this->{lcfirst(substr($name, 3))};
28
            if ($property instanceof \Closure) {
29
                return call_user_func_array($property, $params);
30
            }
31
            return $property;
32
        }
33
        return parent::__call($name, $params);
34
    }
35
}