@@ -20,7 +20,8 @@ discard block |
||
| 20 | 20 | public function testInterceptorCallingEventShouldBeDispatched(): void |
| 21 | 21 | { |
| 22 | 22 | $context = $this->createPathContext(['test', 'test2']); |
| 23 | - $interceptor = new class implements InterceptorInterface { |
|
| 23 | + $interceptor = new class implements InterceptorInterface |
|
| 24 | + { |
|
| 24 | 25 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
| 25 | 26 | { |
| 26 | 27 | return null; |
@@ -39,7 +40,8 @@ discard block |
||
| 39 | 40 | $pipeline = $this->createPipeline(interceptors: [$interceptor], dispatcher: $dispatcher); |
| 40 | 41 | |
| 41 | 42 | $pipeline->withHandler( |
| 42 | - new class implements HandlerInterface { |
|
| 43 | + new class implements HandlerInterface |
|
| 44 | + { |
|
| 43 | 45 | public function handle(CallContextInterface $context): mixed |
| 44 | 46 | { |
| 45 | 47 | return null; |
@@ -36,7 +36,8 @@ discard block |
||
| 36 | 36 | public function withInterceptors(InterceptorInterface ...$interceptors): self |
| 37 | 37 | { |
| 38 | 38 | $clone = clone $this; |
| 39 | - foreach ($interceptors as $interceptor) { |
|
| 39 | + foreach ($interceptors as $interceptor) |
|
| 40 | + { |
|
| 40 | 41 | $clone->interceptors[] = $interceptor; |
| 41 | 42 | } |
| 42 | 43 | |
@@ -55,11 +56,13 @@ discard block |
||
| 55 | 56 | */ |
| 56 | 57 | public function handle(CallContextInterface $context): mixed |
| 57 | 58 | { |
| 58 | - if ($this->handler === null) { |
|
| 59 | + if ($this->handler === null) |
|
| 60 | + { |
|
| 59 | 61 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | - if (isset($this->interceptors[$this->position])) { |
|
| 64 | + if (isset($this->interceptors[$this->position])) |
|
| 65 | + { |
|
| 63 | 66 | $interceptor = $this->interceptors[$this->position]; |
| 64 | 67 | |
| 65 | 68 | $this->dispatcher?->dispatch(new InterceptorCalling(context: $context, interceptor: $interceptor)); |
@@ -66,13 +66,15 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function callAction(string $controller, string $action, array $parameters = []): mixed |
| 68 | 68 | { |
| 69 | - if ($this->context === null) { |
|
| 69 | + if ($this->context === null) |
|
| 70 | + { |
|
| 70 | 71 | return $this->handle( |
| 71 | 72 | new CallContext(Target::fromPathArray([$controller, $action]), $parameters), |
| 72 | 73 | ); |
| 73 | 74 | } |
| 74 | 75 | |
| 75 | - if ($this->context->getTarget()->getPath() === [$controller, $action]) { |
|
| 76 | + if ($this->context->getTarget()->getPath() === [$controller, $action]) |
|
| 77 | + { |
|
| 76 | 78 | return $this->handle($this->context->withArguments($parameters)); |
| 77 | 79 | } |
| 78 | 80 | |
@@ -88,13 +90,15 @@ discard block |
||
| 88 | 90 | */ |
| 89 | 91 | public function handle(CallContextInterface $context): mixed |
| 90 | 92 | { |
| 91 | - if ($this->core === null && $this->handler === null) { |
|
| 93 | + if ($this->core === null && $this->handler === null) |
|
| 94 | + { |
|
| 92 | 95 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
| 93 | 96 | } |
| 94 | 97 | |
| 95 | 98 | $path = $context->getTarget()->getPath(); |
| 96 | 99 | |
| 97 | - if (isset($this->interceptors[$this->position])) { |
|
| 100 | + if (isset($this->interceptors[$this->position])) |
|
| 101 | + { |
|
| 98 | 102 | $interceptor = $this->interceptors[$this->position]; |
| 99 | 103 | $handler = $this->nextWithContext($context); |
| 100 | 104 | |