Total Complexity | 9 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Coverage | 81.82% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | abstract class ObjectProxy |
||
10 | { |
||
11 | use ProxyTrait; |
||
12 | |||
13 | private object $instance; |
||
14 | |||
15 | 3 | public function __construct(object $instance) |
|
16 | { |
||
17 | 3 | $this->instance = $instance; |
|
18 | } |
||
19 | |||
20 | 3 | protected function call(string $methodName, array $arguments) |
|
21 | { |
||
22 | 3 | $this->resetCurrentError(); |
|
23 | 3 | $result = null; |
|
|
|||
24 | 3 | $timeStart = microtime(true); |
|
25 | try { |
||
26 | 3 | $result = $this->callInternal($methodName, $arguments); |
|
27 | } catch (Exception $e) { |
||
28 | $this->repeatError($e); |
||
29 | 3 | } finally { |
|
30 | 3 | $result = $this->executeMethodProxy($methodName, $arguments, $result, $timeStart); |
|
31 | } |
||
32 | |||
33 | 3 | return $this->processResult($result); |
|
34 | } |
||
35 | |||
36 | abstract protected function executeMethodProxy(string $methodName, array $arguments, $result, float $timeStart); |
||
37 | |||
38 | 1 | protected function getNewStaticInstance(object $instance): self |
|
39 | { |
||
40 | 1 | return new static($instance); |
|
41 | } |
||
42 | |||
43 | protected function getInstance(): object |
||
44 | { |
||
45 | return $this->instance; |
||
46 | } |
||
47 | |||
48 | 3 | private function callInternal(string $methodName, array $arguments) |
|
51 | } |
||
52 | |||
53 | 3 | private function processResult($result) |
|
54 | { |
||
60 | } |
||
61 | } |
||
62 |