Passed
Push — master ( de9f16...6836c0 )
by Aleksandr
02:35
created

Testing::module()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace carono\exchange1c\models;
5
6
7
use yii\base\Model;
8
use yii\base\Module;
9
use yii\helpers\ArrayHelper;
10
use yii\helpers\StringHelper;
11
12
abstract class Testing extends Model
13
{
14
    public $name;
15
    public $method;
16
    public $comment;
17
    protected $_result;
18
19
    /**
20
     * @return \carono\exchange1c\ExchangeModule|Module
21
     */
22
    public static function module()
23
    {
24
        return \Yii::$app->controller->module;
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public static function findAll()
31
    {
32
        $reflection = new \ReflectionClass(static::className());
33
        $methods = $reflection->getMethods(\ReflectionMethod::IS_STATIC);
34
        $methods = ArrayHelper::map(array_filter($methods, function ($data) {
35
            return StringHelper::startsWith($data->name, 'test');
36
        }), 'name', 'name');
37
        $data = [];
38
        foreach ($methods as $method) {
39
            if ($test = call_user_func(static::className() . "::$method")) {
40
                $data[] = $test;
41
            }
42
        }
43
        return $data;
44
    }
45
46
    public function testing()
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
47
    {
48
        return !$this->hasErrors();
49
    }
50
}