@@ -20,7 +20,7 @@ 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 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
| 25 | 25 | { |
| 26 | 26 | return null; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $pipeline = $this->createPipeline(interceptors: [$interceptor], dispatcher: $dispatcher); |
| 40 | 40 | |
| 41 | 41 | $pipeline->withHandler( |
| 42 | - new class implements HandlerInterface { |
|
| 42 | + new class implements HandlerInterface{ |
|
| 43 | 43 | public function handle(CallContextInterface $context): mixed |
| 44 | 44 | { |
| 45 | 45 | return null; |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | private function createPipeline( |
| 127 | 127 | array $interceptors = [], |
| 128 | - HandlerInterface|null $lastHandler = null, |
|
| 129 | - EventDispatcherInterface|null $dispatcher = null, |
|
| 128 | + HandlerInterface | null $lastHandler = null, |
|
| 129 | + EventDispatcherInterface | null $dispatcher = null, |
|
| 130 | 130 | ): InterceptorPipeline { |
| 131 | 131 | $pipeline = new InterceptorPipeline($dispatcher); |
| 132 | 132 | |
@@ -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; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function __construct( |
| 29 | 29 | private readonly ?EventDispatcherInterface $dispatcher = null |
| 30 | - ) { |
|
| 30 | + ){ |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -36,7 +36,7 @@ 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 | $clone->interceptors[] = $interceptor; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function handle(CallContextInterface $context): mixed |
| 57 | 57 | { |
| 58 | - if ($this->handler === null) { |
|
| 58 | + if ($this->handler === null){ |
|
| 59 | 59 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if (isset($this->interceptors[$this->position])) { |
|
| 62 | + if (isset($this->interceptors[$this->position])){ |
|
| 63 | 63 | $interceptor = $this->interceptors[$this->position]; |
| 64 | 64 | |
| 65 | 65 | $this->dispatcher?->dispatch(new InterceptorCalling(context: $context, interceptor: $interceptor)); |
@@ -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)); |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function __construct( |
| 33 | 33 | private readonly ?EventDispatcherInterface $dispatcher = null |
| 34 | - ) { |
|
| 34 | + ){ |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function addInterceptor(CoreInterceptorInterface|InterceptorInterface $interceptor): void |
|
| 37 | + public function addInterceptor(CoreInterceptorInterface | InterceptorInterface $interceptor): void |
|
| 38 | 38 | { |
| 39 | 39 | $this->interceptors[] = $interceptor; |
| 40 | 40 | } |
@@ -66,13 +66,13 @@ 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 | return $this->handle( |
| 71 | 71 | new CallContext(Target::fromPathArray([$controller, $action]), $parameters), |
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ($this->context->getTarget()->getPath() === [$controller, $action]) { |
|
| 75 | + if ($this->context->getTarget()->getPath() === [$controller, $action]){ |
|
| 76 | 76 | return $this->handle($this->context->withArguments($parameters)); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function handle(CallContextInterface $context): mixed |
| 90 | 90 | { |
| 91 | - if ($this->core === null && $this->handler === null) { |
|
| 91 | + if ($this->core === null && $this->handler === null){ |
|
| 92 | 92 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $path = $context->getTarget()->getPath(); |
| 96 | 96 | |
| 97 | - if (isset($this->interceptors[$this->position])) { |
|
| 97 | + if (isset($this->interceptors[$this->position])){ |
|
| 98 | 98 | $interceptor = $this->interceptors[$this->position]; |
| 99 | 99 | $handler = $this->nextWithContext($context); |
| 100 | 100 | |
@@ -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 | |