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