Envelope::getPayload()   A
last analyzed

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