diff --git a/src/Bus/NativeMessageBus.php b/src/Bus/NativeMessageBus.php index 7abad5d..978cd6e 100644 --- a/src/Bus/NativeMessageBus.php +++ b/src/Bus/NativeMessageBus.php @@ -4,7 +4,7 @@ use Yceruto\Messenger\Middleware\Middleware; use Yceruto\Messenger\Middleware\MiddlewareStack; -use Yceruto\Messenger\Model\Envelop; +use Yceruto\Messenger\Model\Envelope; use Yceruto\Messenger\Model\Message; final readonly class NativeMessageBus implements MessageBus @@ -21,7 +21,7 @@ public function __construct(iterable $middlewares) public function dispatch(Message $message): mixed { - $envelop = Envelop::wrap($message); + $envelop = Envelope::wrap($message); $this->stack->handle($envelop); diff --git a/src/Middleware/HandlerMiddleware.php b/src/Middleware/HandlerMiddleware.php index 758f61d..c2d50c6 100644 --- a/src/Middleware/HandlerMiddleware.php +++ b/src/Middleware/HandlerMiddleware.php @@ -4,7 +4,7 @@ use Psr\Container\ContainerInterface; use Yceruto\Messenger\Error\HandlerNotFound; -use Yceruto\Messenger\Model\Envelop; +use Yceruto\Messenger\Model\Envelope; /** * Handles a message with a handler. @@ -18,7 +18,7 @@ public function __construct(private ContainerInterface $handlers) /** * {@inheritdoc} */ - public function handle(Envelop $envelop, callable $next): void + public function handle(Envelope $envelop, callable $next): void { $class = get_class($envelop->message); diff --git a/src/Middleware/Middleware.php b/src/Middleware/Middleware.php index c2bbed2..27fe0b4 100644 --- a/src/Middleware/Middleware.php +++ b/src/Middleware/Middleware.php @@ -2,7 +2,7 @@ namespace Yceruto\Messenger\Middleware; -use Yceruto\Messenger\Model\Envelop; +use Yceruto\Messenger\Model\Envelope; /** * Handles an Envelope object and pass control to the next middleware in the stack. @@ -10,7 +10,7 @@ interface Middleware { /** - * @param callable(Envelop): void $next + * @param callable(Envelope): void $next */ - public function handle(Envelop $envelop, callable $next): void; + public function handle(Envelope $envelop, callable $next): void; } diff --git a/src/Middleware/MiddlewareStack.php b/src/Middleware/MiddlewareStack.php index f0e3672..1590442 100644 --- a/src/Middleware/MiddlewareStack.php +++ b/src/Middleware/MiddlewareStack.php @@ -2,7 +2,7 @@ namespace Yceruto\Messenger\Middleware; -use Yceruto\Messenger\Model\Envelop; +use Yceruto\Messenger\Model\Envelope; /** * @internal @@ -16,7 +16,7 @@ public function __construct(private iterable $middlewares) { } - public function handle(Envelop $envelop): void + public function handle(Envelope $envelop): void { $next = static fn (): null => null; @@ -27,7 +27,7 @@ public function handle(Envelop $envelop): void } foreach (array_reverse($middlewares) as $middleware) { - $next = static fn (Envelop $envelop): null => $middleware->handle($envelop, $next); + $next = static fn (Envelope $envelop): null => $middleware->handle($envelop, $next); } $next($envelop); diff --git a/src/Model/Envelop.php b/src/Model/Envelope.php similarity index 92% rename from src/Model/Envelop.php rename to src/Model/Envelope.php index ec71e0e..c7bf61a 100644 --- a/src/Model/Envelop.php +++ b/src/Model/Envelope.php @@ -2,7 +2,7 @@ namespace Yceruto\Messenger\Model; -final class Envelop +final class Envelope { public mixed $result = null; diff --git a/tests/Middleware/HandlerMiddlewareTest.php b/tests/Middleware/HandlerMiddlewareTest.php index 38f3507..2f27008 100644 --- a/tests/Middleware/HandlerMiddlewareTest.php +++ b/tests/Middleware/HandlerMiddlewareTest.php @@ -6,7 +6,7 @@ use Yceruto\Messenger\Error\HandlerNotFound; use Yceruto\Messenger\Handler\HandlersLocator; use Yceruto\Messenger\Middleware\HandlerMiddleware; -use Yceruto\Messenger\Model\Envelop; +use Yceruto\Messenger\Model\Envelope; use Yceruto\Messenger\Tests\Fixtures\CreateProduct; use Yceruto\Messenger\Tests\Fixtures\MessageWithoutHandler; @@ -24,7 +24,7 @@ protected function setUp(): void public function testHandle(): void { $message = new CreateProduct(); - $envelop = Envelop::wrap($message); + $envelop = Envelope::wrap($message); $this->handlerMiddleware->handle($envelop, static fn () => null); $this->assertSame($message, $envelop->result); @@ -35,7 +35,7 @@ public function testNotHandlerFound(): void $this->expectException(HandlerNotFound::class); $this->expectExceptionMessage('Handler not found for message "Yceruto\Messenger\Tests\Fixtures\MessageWithoutHandler"'); - $envelop = Envelop::wrap(new MessageWithoutHandler()); + $envelop = Envelope::wrap(new MessageWithoutHandler()); $this->handlerMiddleware->handle($envelop, static fn () => null); } } diff --git a/tests/Middleware/MiddlewareStackTest.php b/tests/Middleware/MiddlewareStackTest.php index 616bf26..3ba337f 100644 --- a/tests/Middleware/MiddlewareStackTest.php +++ b/tests/Middleware/MiddlewareStackTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; use Yceruto\Messenger\Middleware\MiddlewareStack; use Yceruto\Messenger\Middleware\Middleware; -use Yceruto\Messenger\Model\Envelop; +use Yceruto\Messenger\Model\Envelope; use Yceruto\Messenger\Tests\Fixtures\CreateProduct; class MiddlewareStackTest extends TestCase @@ -13,28 +13,28 @@ class MiddlewareStackTest extends TestCase public function testHandle(): void { $middleware1 = new class() implements Middleware { - public function handle(Envelop $envelop, callable $next): void + public function handle(Envelope $envelop, callable $next): void { $envelop->result = '1'; $next($envelop); } }; $middleware2 = new class() implements Middleware { - public function handle(Envelop $envelop, callable $next): void + public function handle(Envelope $envelop, callable $next): void { $envelop->result .= '2'; $next($envelop); } }; $middleware3 = new class() implements Middleware { - public function handle(Envelop $envelop, callable $next): void + public function handle(Envelope $envelop, callable $next): void { $envelop->result .= '3'; $next($envelop); } }; $stack = new MiddlewareStack([$middleware1, $middleware2, $middleware3]); - $envelop = Envelop::wrap(new CreateProduct()); + $envelop = Envelope::wrap(new CreateProduct()); $stack->handle($envelop); $this->assertSame('123', $envelop->result);