| Conditions | 3 |
| Paths | 1 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3.1825 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | 3 | public function getLazyServiceDefinition(string $className, callable $definition): VirtualProxyInterface |
|
| 32 | { |
||
| 33 | 3 | return $this->lazyLoadingFactory->createProxy( |
|
| 34 | 3 | $className, |
|
| 35 | // this fancy method signature is required by lazy loading factory |
||
| 36 | function (&$wrappedObject, $proxy, $method, $parameters, &$initializer) use ($className, $definition) { |
||
| 37 | 1 | $wrappedObject = $definition(); |
|
| 38 | 1 | $initializer = null; |
|
| 39 | |||
| 40 | // extra defensive programming in action |
||
| 41 | 1 | if (!$wrappedObject instanceof $className) { |
|
| 42 | throw new \InvalidArgumentException(sprintf( |
||
| 43 | 'Object "%s" is not instance of "%s"', |
||
| 44 | \is_object($wrappedObject) ? \get_class($wrappedObject) : \gettype($wrappedObject), |
||
| 45 | $className |
||
| 46 | )); |
||
| 47 | } |
||
| 48 | |||
| 49 | 1 | return true; |
|
| 50 | 3 | } |
|
| 51 | ); |
||
| 52 | } |
||
| 53 | } |
||
| 54 |