Total Complexity | 6 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 45.45% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
8 | final class Envelope |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | private $title; |
||
14 | |||
15 | /** |
||
16 | * @var mixed |
||
17 | */ |
||
18 | private $payload; |
||
19 | |||
20 | /** |
||
21 | * @var DateTimeInterface |
||
22 | */ |
||
23 | private $timestamp; |
||
24 | |||
25 | 4 | public function __construct($payload, ?string $title = null, ?DateTimeInterface $timestamp = null) |
|
26 | { |
||
27 | 4 | $this->payload = $payload; |
|
28 | 4 | $this->title = $title ?: bin2hex(random_bytes(7)); |
|
29 | 4 | $this->timestamp = $timestamp ?: new DateTimeImmutable(); |
|
30 | 4 | } |
|
31 | |||
32 | /** |
||
33 | * @return string |
||
34 | */ |
||
35 | public function getTitle(): string |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @return mixed |
||
42 | */ |
||
43 | public function getPayload() |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return DateTimeInterface |
||
50 | */ |
||
51 | public function getTimestamp(): DateTimeInterface |
||
54 | } |
||
55 | } |
||
56 |