| Conditions | 5 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | 6 | public function onKernelView(GetResponseForControllerResultEvent $event): void |
|
| 31 | { |
||
| 32 | 6 | $apiVersion = $this->apiVersionProvider->getApiVersion(); |
|
| 33 | |||
| 34 | 6 | if (null === $apiVersion) { |
|
| 35 | 1 | return; |
|
| 36 | } |
||
| 37 | |||
| 38 | 5 | $controllerResult = $event->getControllerResult(); |
|
| 39 | |||
| 40 | 5 | if ($controllerResult instanceof VersionedViewInterface) { |
|
| 41 | 4 | $controllerResult->setVersion($apiVersion); |
|
| 42 | |||
| 43 | 4 | return; |
|
| 44 | } |
||
| 45 | |||
| 46 | 1 | if (class_exists(View::class) && is_a($controllerResult, View::class)) { |
|
| 47 | 1 | $context = $controllerResult->getContext(); |
|
| 48 | |||
| 49 | 1 | $context->setVersion(/* @scrutinizer ignore-type */$apiVersion); |
|
| 50 | |||
| 51 | 1 | $controllerResult->setContext($context); |
|
| 52 | } |
||
| 55 |