Passed
Push — master ( a9cf05...a95418 )
by Aleksandr
02:23
created

Action::__call()   A

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
15
    public function init()
16
    {
17
        if ($this->layout) {
18
            $this->controller->layout = $this->layout;
19
        }
20
        parent::init();
21
    }
22
23
    public function __call($name, $params)
24
    {
25
        if (StringHelper::startsWith($name, 'getMessage')) {
26
            $property = $this->{lcfirst(substr($name, 3))};
27
            if ($property instanceof \Closure) {
28
                return call_user_func_array($property, $params);
29
            }
30
            return $property;
31
        }
32
        return parent::__call($name, $params);
33
    }
34
}