Passed
Push — main ( 1806bf...21adec )
by Fractal
12:23
created

PendingEnvelope   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 4
b 0
f 0
dl 0
loc 16
rs 10
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
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 24 at column 6
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