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

Action   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 13
c 1
b 0
f 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 10 3
A init() 0 6 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
}