Passed
Push — main ( 6af5e8...b57ba9 )
by Fractal
01:44
created

PendingEnvelope::isTransactional()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\TransactionalMessenger\ValueObject;
6
7
use FRZB\Component\TransactionalMessenger\Enum\CommitType;
8
use FRZB\Component\TransactionalMessenger\Helper\TransactionHelper;
0 ignored issues
show
Bug introduced by
The type FRZB\Component\Transacti...elper\TransactionHelper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use JetBrains\PhpStorm\Immutable;
10
use Symfony\Component\Messenger\Envelope;
11
12
/** @template T of object */
13
#[Immutable]
14
final class PendingEnvelope
15
{
16
    public function __construct(
17
        public readonly Envelope $envelope,
18
        public readonly \DateTimeImmutable $whenPended = new \DateTimeImmutable(),
19
    ) {
20
    }
21
22
    public function getMessageClass(): string
23
    {
24
        return $this->envelope->getMessage()::class;
25
    }
26
27
    public function isTransactional(CommitType ...$commitTypes): bool
28
    {
29
        return TransactionHelper::isDispatchable($this->getMessageClass(), ...$commitTypes);
30
    }
31
}
32