Action   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 14
c 1
b 0
f 0
dl 0
loc 25
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
    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
}