Total Complexity | 9 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 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 | ||
24 | 1 | if (self::$builtinMethods !== []) { |
|
25 | return; |
||
26 | 31 | } |
|
27 | |||
28 | $this->setBuildInMethods(); |
||
29 | } |
||
30 | |||
31 | 27 | /** |
|
32 | * {@inheritDoc} |
||
33 | 27 | */ |
|
34 | public function matchesClass(ReflectionClass $class, array $arguments): bool |
||
35 | { |
||
36 | unset($class, $arguments); |
||
37 | |||
38 | return true; |
||
39 | 5 | } |
|
40 | |||
41 | 5 | /** |
|
42 | * {@inheritDoc} |
||
43 | 5 | */ |
|
44 | public function matchesMethod(ReflectionMethod $method, array $arguments): bool |
||
45 | { |
||
46 | 1 | unset($arguments); |
|
47 | |||
48 | 1 | return ! ($this->isMagicMethod($method->name) || $this->isBuiltinMethod($method->name)); |
|
49 | 1 | } |
|
50 | 1 | ||
51 | private function setBuildInMethods(): void |
||
52 | 1 | { |
|
53 | $methods = (new ReflectionClass(ArrayObject::class))->getMethods(); |
||
54 | 5 | foreach ($methods as $method) { |
|
55 | self::$builtinMethods[] = $method->name; |
||
56 | 5 | } |
|
57 | } |
||
58 | |||
59 | private function isMagicMethod(string $name): bool |
||
62 | } |
||
63 | |||
64 | 5 | private function isBuiltinMethod(string $name): bool |
|
67 | } |
||
68 | } |
||
69 |