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

ScheduledMessage::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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