-
Notifications
You must be signed in to change notification settings - Fork 0
/
Message.php
53 lines (46 loc) · 1.23 KB
/
Message.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
namespace voniersa\twitch\livechat;
final class Message
{
private function __construct(
private readonly string $messageText,
private readonly UserName $userName,
private readonly ChannelName $channelName
) {
}
/**
* @param string $messageText text that was sent to live chat
* @param UserName $userName name of the chat user
* @param ChannelName $channelName name of the channel where the message was sent
* @return Message value object
*/
public static function fromParams(
string $messageText,
UserName $userName,
ChannelName $channelName
): Message {
return new self($messageText, $userName, $channelName);
}
/**
* @return string text that was sent to live chat
*/
public function __toString(): string
{
return $this->messageText;
}
/**
* @return UserName object of the chat user
*/
public function getUserName(): UserName
{
return $this->userName;
}
/**
* @return ChannelName object of the channel where the message was sent
*/
public function getChannelName(): ChannelName
{
return $this->channelName;
}
}