Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
Msg | |
100.00% |
10 / 10 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
getMsgId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDomain | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getParameters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setContent | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
clearContent | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
contentIsSet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * @author: Doug Wilbourne (dougwilbourne@gmail.com) |
5 | */ |
6 | |
7 | declare(strict_types=1); |
8 | |
9 | namespace pvc\msg; |
10 | |
11 | use pvc\interfaces\msg\MsgInterface; |
12 | |
13 | /** |
14 | * Class Msg |
15 | */ |
16 | class Msg implements MsgInterface |
17 | { |
18 | /** |
19 | * @var string |
20 | * this is the id that will be used to retrieve the full message from the domain catalog |
21 | */ |
22 | protected string $msgId; |
23 | |
24 | /** |
25 | * @var string |
26 | * the MsgFrmtr will use this to make sure the correct catalog is loaded (or load the correct |
27 | * one) before attempting to retrieve the message text |
28 | */ |
29 | protected string $domain; |
30 | |
31 | /** |
32 | * @var array<mixed> |
33 | * parameters used to fill any placeholders in the message text |
34 | */ |
35 | protected array $parameters; |
36 | |
37 | /** |
38 | * @return string |
39 | */ |
40 | public function getMsgId(): string |
41 | { |
42 | return $this->msgId; |
43 | } |
44 | |
45 | /** |
46 | * @return string |
47 | */ |
48 | public function getDomain(): string |
49 | { |
50 | return $this->domain; |
51 | } |
52 | |
53 | /** |
54 | * @return array<mixed> |
55 | */ |
56 | public function getParameters(): array |
57 | { |
58 | return $this->parameters ?? []; |
59 | } |
60 | |
61 | /** |
62 | * @param non-empty-string $domain |
63 | * @param non-empty-string $msgId |
64 | * @param mixed[] $parameters |
65 | */ |
66 | public function setContent(string $domain, string $msgId, array $parameters = []): void |
67 | { |
68 | $this->domain = $domain; |
69 | $this->msgId = $msgId; |
70 | $this->parameters = $parameters; |
71 | } |
72 | |
73 | /** |
74 | * clear |
75 | */ |
76 | public function clearContent(): void |
77 | { |
78 | unset($this->domain); |
79 | unset($this->msgId); |
80 | unset($this->parameters); |
81 | } |
82 | |
83 | /** |
84 | * contentIsSet |
85 | * @return bool |
86 | */ |
87 | public function contentIsSet(): bool |
88 | { |
89 | return isset($this->msgId); |
90 | } |
91 | } |