Completed
Push — master ( 4b9f01...160a67 )
by Damian
02:21
created

Envelope::getPayload()   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 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
namespace Initx;
4
5
use DateTime;
6
use DateTimeInterface;
7
8
final class Envelope
9
{
10
    /**
11
     * @var string
12
     */
13
    private $title;
14
15
    /**
16
     * @var string
17
     */
18
    private $payload;
19
20
    /**
21
     * @var DateTimeInterface
22
     */
23
    private $timestamp;
24
25 5
    public function __construct(string $payload, ?string $title = null, ?DateTimeInterface $timestamp = null)
26
    {
27 5
        $this->title = $title ?: bin2hex(random_bytes(7));
28 5
        $this->timestamp = $timestamp ?: new DateTime();
29 5
        $this->payload = $payload;
30 5
    }
31
32
    /**
33
     * @return string
34
     */
35 1
    public function getTitle(): string
36
    {
37 1
        return $this->title;
38
    }
39
40
    /**
41
     * @return string
42
     */
43 1
    public function getPayload(): string
44
    {
45 1
        return $this->payload;
46
    }
47
48
    /**
49
     * @return DateTimeInterface
50
     */
51 1
    public function getTimestamp(): DateTimeInterface
52
    {
53 1
        return $this->timestamp;
54
    }
55
}
56