| Total Complexity | 9 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 90.91% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | abstract class ObjectProxy |
||
| 10 | { |
||
| 11 | use ProxyTrait; |
||
| 12 | |||
| 13 | private object $instance; |
||
| 14 | |||
| 15 | 4 | public function __construct(object $instance) |
|
| 16 | { |
||
| 17 | 4 | $this->instance = $instance; |
|
| 18 | } |
||
| 19 | |||
| 20 | 4 | protected function call(string $methodName, array $arguments) |
|
| 21 | { |
||
| 22 | 4 | $this->resetCurrentError(); |
|
| 23 | 4 | $result = null; |
|
|
|
|||
| 24 | 4 | $timeStart = microtime(true); |
|
| 25 | try { |
||
| 26 | 4 | $result = $this->callInternal($methodName, $arguments); |
|
| 27 | 1 | } catch (Exception $e) { |
|
| 28 | 1 | $this->repeatError($e); |
|
| 29 | 3 | } finally { |
|
| 30 | 4 | $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 | 4 | private function callInternal(string $methodName, array $arguments) |
|
| 51 | } |
||
| 52 | |||
| 53 | 3 | private function processResult($result) |
|
| 60 | } |
||
| 61 | } |
||
| 62 |