Total Complexity | 9 |
Total Lines | 73 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
16 | class MethodMetadata implements \Serializable |
||
17 | { |
||
18 | use SerializationHelper; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | public $class; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | public $name; |
||
29 | |||
30 | /** |
||
31 | * @var \ReflectionMethod |
||
32 | */ |
||
33 | 9 | private $reflection; |
|
34 | |||
35 | 9 | public function __construct(string $class, string $name) |
|
36 | 9 | { |
|
37 | 9 | $this->class = $class; |
|
38 | $this->name = $name; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param mixed[] $args |
||
43 | * |
||
44 | 1 | * @return mixed |
|
45 | */ |
||
46 | 1 | public function invoke(object $obj, array $args = []) |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return mixed |
||
53 | */ |
||
54 | public function __get(string $propertyName) |
||
55 | { |
||
56 | 2 | if ('reflection' === $propertyName) { |
|
57 | return $this->getReflection(); |
||
58 | 2 | } |
|
59 | |||
60 | return $this->$propertyName; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param mixed $value |
||
65 | */ |
||
66 | public function __set(string $propertyName, $value): void |
||
69 | } |
||
70 | 2 | ||
71 | private function getReflection(): \ReflectionMethod |
||
72 | 2 | { |
|
73 | 2 | if (null === $this->reflection) { |
|
74 | $this->reflection = new \ReflectionMethod($this->class, $this->name); |
||
75 | $this->reflection->setAccessible(true); |
||
76 | } |
||
77 | |||
78 | 4 | return $this->reflection; |
|
79 | } |
||
80 | 4 | ||
81 | 3 | protected function serializeToArray(): array |
|
82 | { |
||
83 | return [$this->class, $this->name]; |
||
84 | 1 | } |
|
85 | |||
86 | protected function unserializeFromArray(array $data): void |
||
89 | } |
||
90 | } |
||
91 |