SUExecutor::setups()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 7
nc 5
nop 0
dl 0
loc 15
rs 9.6111
c 0
b 0
f 0
1
<?php
2
/**
3
 * Setup executor
4
 * User: moyo
5
 * Date: 2018/5/29
6
 * Time: 2:14 PM
7
 */
8
9
namespace Carno\Web\Chips\Router;
10
11
use Carno\Web\Router\Setup;
12
use ReflectionClass;
13
use ReflectionMethod;
14
15
trait SUExecutor
16
{
17
    /**
18
     * @return array
19
     */
20
    protected function setups() : array
21
    {
22
        $methods = [];
23
24
        foreach ((new ReflectionClass($this))->getMethods(ReflectionMethod::IS_PROTECTED) as $method) {
25
            foreach ($method->getParameters() as $parameter) {
26
                if ($required = $parameter->getClass()) {
27
                    if ($required->getName() === Setup::class) {
28
                        $methods[] = $method->getName();
29
                    }
30
                }
31
            }
32
        }
33
34
        return $methods;
35
    }
36
}
37