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

PendingEnvelope   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
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 17
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isTransactional() 0 3 1
A getMessageClass() 0 3 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