From b4c1ec817dcae751f25abd43a8de986c65d07a8f Mon Sep 17 00:00:00 2001 From: David Badura Date: Wed, 7 Feb 2024 11:01:13 +0100 Subject: [PATCH] remove event bus stack & some small improvements --- src/Console/InvalidArgumentGiven.php | 4 ++-- src/EventBus/EventBusStackBuilder.php | 30 -------------------------- src/Outbox/DoctrineOutboxStore.php | 3 +-- src/Outbox/OutboxHeaderIssue.php | 4 ++-- tests/Unit/Console/InputHelperTest.php | 8 +++---- 5 files changed, 9 insertions(+), 40 deletions(-) delete mode 100644 src/EventBus/EventBusStackBuilder.php diff --git a/src/Console/InvalidArgumentGiven.php b/src/Console/InvalidArgumentGiven.php index 0e4a76560..9ad39b202 100644 --- a/src/Console/InvalidArgumentGiven.php +++ b/src/Console/InvalidArgumentGiven.php @@ -6,7 +6,7 @@ use InvalidArgumentException; -use function gettype; +use function get_debug_type; use function sprintf; final class InvalidArgumentGiven extends InvalidArgumentException @@ -19,7 +19,7 @@ public function __construct( sprintf( 'Invalid argument given: need type "%s" got "%s"', $need, - gettype($value), + get_debug_type($value), ), ); } diff --git a/src/EventBus/EventBusStackBuilder.php b/src/EventBus/EventBusStackBuilder.php deleted file mode 100644 index 2d6e7efcc..000000000 --- a/src/EventBus/EventBusStackBuilder.php +++ /dev/null @@ -1,30 +0,0 @@ - */ - private array $stack = []; - - public function addFist(EventBus $eventBus): self - { - $this->stack = [$eventBus, ...$this->stack]; - - return $this; - } - - public function addLast(EventBus $eventBus): self - { - $this->stack[] = $eventBus; - - return $this; - } - - public function build(): EventBus - { - return new ChainEventBus($this->stack); - } -} diff --git a/src/Outbox/DoctrineOutboxStore.php b/src/Outbox/DoctrineOutboxStore.php index db0fbc0ea..a722211c9 100644 --- a/src/Outbox/DoctrineOutboxStore.php +++ b/src/Outbox/DoctrineOutboxStore.php @@ -60,8 +60,7 @@ public function retrieveOutboxMessages(int|null $limit = null): array function (array $data) { $message = $this->messageSerializer->deserialize($data['message']); - return $message - ->withCustomHeader(self::HEADER_OUTBOX_IDENTIFIER, $data['id']); + return $message->withCustomHeader(self::HEADER_OUTBOX_IDENTIFIER, $data['id']); }, $result, ); diff --git a/src/Outbox/OutboxHeaderIssue.php b/src/Outbox/OutboxHeaderIssue.php index 817e1d8c2..0a755d51b 100644 --- a/src/Outbox/OutboxHeaderIssue.php +++ b/src/Outbox/OutboxHeaderIssue.php @@ -6,7 +6,7 @@ use RuntimeException; -use function gettype; +use function get_debug_type; use function sprintf; final class OutboxHeaderIssue extends RuntimeException @@ -18,6 +18,6 @@ public static function missingHeader(string $header): self public static function invalidHeaderType(mixed $value): self { - return new self(sprintf('Invalid header given: need type "int" got "%s"', gettype($value))); + return new self(sprintf('Invalid header given: need type "int" got "%s"', get_debug_type($value))); } } diff --git a/tests/Unit/Console/InputHelperTest.php b/tests/Unit/Console/InputHelperTest.php index 44610b1da..66f1113f3 100644 --- a/tests/Unit/Console/InputHelperTest.php +++ b/tests/Unit/Console/InputHelperTest.php @@ -19,7 +19,7 @@ public function testValidString(): void public function testInvalidString(): void { $this->expectException(InvalidArgumentGiven::class); - $this->expectExceptionMessage('Invalid argument given: need type "string" got "integer"'); + $this->expectExceptionMessage('Invalid argument given: need type "string" got "int"'); InputHelper::string(1); } @@ -37,7 +37,7 @@ public function testValidNullableStringIsNull(): void public function testInvalidNullableString(): void { $this->expectException(InvalidArgumentGiven::class); - $this->expectExceptionMessage('Invalid argument given: need type "string|null" got "integer"'); + $this->expectExceptionMessage('Invalid argument given: need type "string|null" got "int"'); InputHelper::nullableString(1); } @@ -50,7 +50,7 @@ public function testValidBoolean(): void public function testInvalidBoolean(): void { $this->expectException(InvalidArgumentGiven::class); - $this->expectExceptionMessage('Invalid argument given: need type "bool" got "integer"'); + $this->expectExceptionMessage('Invalid argument given: need type "bool" got "int"'); InputHelper::bool(1); } @@ -68,7 +68,7 @@ public function testValidNullInt(): void public function testInvalidInt(): void { $this->expectException(InvalidArgumentGiven::class); - $this->expectExceptionMessage('Invalid argument given: need type "int|null" got "boolean"'); + $this->expectExceptionMessage('Invalid argument given: need type "int|null" got "bool"'); InputHelper::nullableInt(true); }