Passed
Push — master ( 20c244...2664aa )
by Joachim
02:10
created

ScheduledMessage   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 44.44%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 23
c 1
b 0
f 0
dl 0
loc 62
ccs 8
cts 18
cp 0.4444
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getState() 0 3 1
A getDispatchAt() 0 3 1
A addError() 0 3 1
A getSerializedMessage() 0 3 1
A getBus() 0 3 1
A __construct() 0 6 1
A getId() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\MessageSchedulerBundle\Entity;
6
7
use DateTimeInterface;
8
use Ramsey\Uuid\Uuid;
9
10
class ScheduledMessage
11
{
12
    public const STATE_PENDING = 'pending';
13
14
    public const STATE_DISPATCHED = 'dispatched';
15
16
    public const STATE_PROCESSING = 'processing';
17
18
    public const STATE_FAILED = 'failed';
19
20
    public const STATE_SUCCESSFUL = 'successful';
21
22
    protected string $id;
23
24
    protected string $serializedMessage;
25
26
    protected DateTimeInterface $dispatchAt;
27
28
    protected ?string $bus;
29
30
    protected string $state = self::STATE_PENDING;
31
32
    protected array $errors = [];
33
34
    protected ?int $version = null;
35
36 1
    public function __construct(string $serializedMessage, DateTimeInterface $dispatchAt, string $bus = null)
37
    {
38 1
        $this->id = (string) Uuid::uuid4();
39 1
        $this->serializedMessage = $serializedMessage;
40 1
        $this->dispatchAt = $dispatchAt;
41 1
        $this->bus = $bus;
42 1
    }
43
44 1
    public function getId(): string
45
    {
46 1
        return $this->id;
47
    }
48
49
    public function getSerializedMessage(): string
50
    {
51
        return $this->serializedMessage;
52
    }
53
54
    public function getDispatchAt(): DateTimeInterface
55
    {
56
        return $this->dispatchAt;
57
    }
58
59
    public function getBus(): ?string
60
    {
61
        return $this->bus;
62
    }
63
64
    public function getState(): string
65
    {
66
        return $this->state;
67
    }
68
69
    public function addError(string $error): void
70
    {
71
        $this->errors[] = $error;
72
    }
73
}
74