Total Complexity | 9 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | final class AnyMatcher extends AbstractMatcher |
||
16 | { |
||
17 | /** @var string[] */ |
||
18 | private static $builtinMethods = []; |
||
19 | |||
20 | 31 | public function __construct() |
|
21 | { |
||
22 | 31 | parent::__construct(); |
|
23 | 31 | if (self::$builtinMethods === []) { |
|
24 | 1 | $this->setBuildInMethods(); |
|
25 | } |
||
26 | 31 | } |
|
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | 27 | public function matchesClass(ReflectionClass $class, array $arguments): bool |
|
32 | { |
||
33 | 27 | unset($class, $arguments); |
|
34 | |||
35 | return true; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | 5 | * {@inheritdoc} |
|
40 | */ |
||
41 | 5 | public function matchesMethod(ReflectionMethod $method, array $arguments): bool |
|
42 | { |
||
43 | 5 | unset($arguments); |
|
44 | |||
45 | return ! ($this->isMagicMethod($method->name) || $this->isBuiltinMethod($method->name)); |
||
46 | 1 | } |
|
47 | |||
48 | 1 | private function setBuildInMethods(): void |
|
49 | 1 | { |
|
50 | 1 | $methods = (new ReflectionClass(ArrayObject::class))->getMethods(); |
|
51 | foreach ($methods as $method) { |
||
52 | 1 | self::$builtinMethods[] = $method->name; |
|
53 | } |
||
54 | 5 | } |
|
55 | |||
56 | 5 | private function isMagicMethod(string $name): bool |
|
59 | } |
||
60 | |||
61 | private function isBuiltinMethod(string $name): bool |
||
64 | 5 | } |
|
65 | } |
||
66 |