MethodsCollector::collectMethods()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 2
b 0
f 0
nc 3
nop 2
dl 0
loc 11
ccs 0
cts 7
cp 0
crap 12
rs 10
1
<?php
2
3
namespace Terranet\Administrator\Traits;
4
5
use ReflectionClass;
6
use ReflectionMethod;
7
8
trait MethodsCollector
9
{
10
    /**
11
     * @param $instance
12
     * @param int $filter
13
     *
14
     * @return \ReflectionMethod[]
15
     */
16
    protected function collectMethods($instance, $filter = ReflectionMethod::IS_PUBLIC)
17
    {
18
        static $methodsCache = null;
19
20
        if (null === $methodsCache) {
21
            $methodsCache = $instance
22
                ? (new ReflectionClass($instance))->getMethods($filter)
23
                : [];
24
        }
25
26
        return $methodsCache;
27
    }
28
}
29