1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ProjetNormandie\TwitchBundle\Model\Twitch; |
6
|
|
|
|
7
|
|
|
use DateTime; |
8
|
|
|
|
9
|
|
|
class Stream implements \JsonSerializable |
10
|
|
|
{ |
11
|
|
|
private ?string $id = null; |
12
|
|
|
private string $username = ''; |
13
|
|
|
private string $gameId = ''; |
14
|
|
|
private string $gameName = ''; |
15
|
|
|
private string $type = ''; |
16
|
|
|
private string $title = ''; |
17
|
|
|
private string $viewerCount = ''; |
18
|
|
|
private ?DateTime $startedAt = null; |
19
|
|
|
private string $language = 'en'; |
20
|
|
|
private string $thumnailUrl = ''; |
21
|
|
|
private array $tagIds = []; |
22
|
|
|
private array $tags = []; |
23
|
|
|
private bool $isMature = true; |
24
|
|
|
|
25
|
|
|
public function getGameName(): string |
26
|
|
|
{ |
27
|
|
|
return $this->gameName; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function setGameName(string $gameName): void |
31
|
|
|
{ |
32
|
|
|
$this->gameName = $gameName; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function getId(): string |
36
|
|
|
{ |
37
|
|
|
return $this->id; |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function setId(string $id): void |
41
|
|
|
{ |
42
|
|
|
$this->id = $id; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getUsername(): string |
46
|
|
|
{ |
47
|
|
|
return $this->username; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function setUsername(string $username): void |
51
|
|
|
{ |
52
|
|
|
$this->username = $username; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getGameId(): string |
56
|
|
|
{ |
57
|
|
|
return $this->gameId; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setGameId(string $gameId): void |
61
|
|
|
{ |
62
|
|
|
$this->gameId = $gameId; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getType(): string |
66
|
|
|
{ |
67
|
|
|
return $this->type; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function setType(string $type): void |
71
|
|
|
{ |
72
|
|
|
$this->type = $type; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getTitle(): string |
76
|
|
|
{ |
77
|
|
|
return $this->title; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function setTitle(string $title): void |
81
|
|
|
{ |
82
|
|
|
$this->title = $title; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getViewerCount(): string |
86
|
|
|
{ |
87
|
|
|
return $this->viewerCount; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function setViewerCount(string $viewerCount): void |
91
|
|
|
{ |
92
|
|
|
$this->viewerCount = $viewerCount; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function getStartedAt(): DateTime |
96
|
|
|
{ |
97
|
|
|
return $this->startedAt; |
|
|
|
|
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function setStartedAt(mixed $startedAt): void |
101
|
|
|
{ |
102
|
|
|
if (is_string($startedAt)) { |
103
|
|
|
$this->startedAt = new DateTime($startedAt); |
104
|
|
|
} else { |
105
|
|
|
$this->startedAt = $startedAt; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getLanguage(): string |
110
|
|
|
{ |
111
|
|
|
return $this->language; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function setLanguage(string $language): void |
115
|
|
|
{ |
116
|
|
|
$this->language = $language; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function getThumnailUrl(): string |
120
|
|
|
{ |
121
|
|
|
return $this->thumnailUrl; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function setThumnailUrl(string $thumnailUrl): void |
125
|
|
|
{ |
126
|
|
|
$this->thumnailUrl = $thumnailUrl; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function getTagIds(): array |
130
|
|
|
{ |
131
|
|
|
return $this->tagIds; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function setTagIds(array $tagIds): void |
135
|
|
|
{ |
136
|
|
|
$this->tagIds = $tagIds; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function getTags(): array |
140
|
|
|
{ |
141
|
|
|
return $this->tags; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function setTags(array $tags): void |
145
|
|
|
{ |
146
|
|
|
$this->tags = $tags; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function isMature(): bool |
150
|
|
|
{ |
151
|
|
|
return $this->isMature; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function setIsMature(bool $isMature): void |
155
|
|
|
{ |
156
|
|
|
$this->isMature = $isMature; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @return array<mixed> |
162
|
|
|
*/ |
163
|
|
|
public function jsonSerialize(): array |
164
|
|
|
{ |
165
|
|
|
return [ |
166
|
|
|
'id' => $this->id, |
167
|
|
|
'user_name' => $this->username, |
168
|
|
|
'game_id' => $this->gameId, |
169
|
|
|
'game_name' => $this->gameName, |
170
|
|
|
'type' => $this->type, |
171
|
|
|
'title' => $this->title, |
172
|
|
|
'viewer_count' => $this->viewerCount, |
173
|
|
|
'started_at' => $this->startedAt !== null ?? $this->startedAt->format('Y-m-d H:i:s'), |
|
|
|
|
174
|
|
|
'language' => $this->language, |
175
|
|
|
'thumnail_url' => $this->thumnailUrl, |
176
|
|
|
'tag_ids' => $this->tagIds, |
177
|
|
|
'tags' => $this->tags, |
178
|
|
|
'is_mature' => $this->isMature, |
179
|
|
|
]; |
180
|
|
|
} |
181
|
|
|
} |