fractalzombie /
frzb-transactional-messenger
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /** |
||
| 6 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||
| 7 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
| 8 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||
| 9 | * |
||
| 10 | * Copyright (c) 2024 Mykhailo Shtanko [email protected] |
||
| 11 | * |
||
| 12 | * For the full copyright and license information, please view the LICENSE.MD |
||
| 13 | * file that was distributed with this source code. |
||
| 14 | */ |
||
| 15 | |||
| 16 | namespace FRZB\Component\TransactionalMessenger\ValueObject; |
||
| 17 | |||
| 18 | use FRZB\Component\TransactionalMessenger\Enum\CommitType; |
||
| 19 | use FRZB\Component\TransactionalMessenger\Helper\TransactionHelper; |
||
| 20 | use JetBrains\PhpStorm\Immutable; |
||
| 21 | use Symfony\Component\Messenger\Envelope; |
||
| 22 | |||
| 23 | #[Immutable] |
||
| 24 | final readonly class PendingEnvelope |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 25 | { |
||
| 26 | public function __construct( |
||
| 27 | public Envelope $envelope, |
||
| 28 | public \DateTimeImmutable $whenPended = new \DateTimeImmutable(), |
||
| 29 | ) {} |
||
| 30 | |||
| 31 | public function getMessageClass(): string |
||
| 32 | { |
||
| 33 | return $this->envelope->getMessage()::class; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function isTransactional(CommitType ...$commitTypes): bool |
||
| 37 | { |
||
| 38 | return TransactionHelper::isDispatchable($this->getMessageClass(), ...$commitTypes); |
||
| 39 | } |
||
| 40 | } |
||
| 41 |