1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ProjetNormandie\TwitchBundle\Entity; |
6
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\ApiProperty; |
8
|
|
|
use Doctrine\ORM\Mapping as ORM; |
9
|
|
|
use ProjetNormandie\TwitchBundle\Repository\StreamRepository; |
10
|
|
|
|
11
|
|
|
#[ORM\Table(name: 'pnt_stream')] |
12
|
|
|
#[ORM\Entity(repositoryClass: StreamRepository::class)] |
13
|
|
|
class Stream |
14
|
|
|
{ |
15
|
|
|
#[ApiProperty(identifier: true)] |
16
|
|
|
#[ORM\Id, ORM\Column, ORM\GeneratedValue] |
17
|
|
|
protected ?int $id = null; |
18
|
|
|
|
19
|
|
|
#[ORM\Column(length: 20, unique: true)] |
20
|
|
|
protected string $externalId; |
21
|
|
|
|
22
|
|
|
#[ORM\ManyToOne(targetEntity: Game::class, inversedBy: 'streams')] |
23
|
|
|
#[ORM\JoinColumn(name:'game_id', referencedColumnName:'id', nullable:true)] |
24
|
|
|
private ?Game $game; |
25
|
|
|
|
26
|
|
|
#[ORM\ManyToOne(targetEntity: Channel::class, inversedBy: 'streams')] |
27
|
|
|
#[ORM\JoinColumn(name:'channel_id', referencedColumnName:'id', nullable:false)] |
28
|
|
|
private Channel $channel; |
29
|
|
|
|
30
|
|
|
#[ORM\Column(nullable: true)] |
31
|
|
|
private ?\DateTime $startedAt = null; |
32
|
|
|
|
33
|
|
|
#[ORM\Column(length: 255, nullable: false)] |
34
|
|
|
protected string $title; |
35
|
|
|
|
36
|
|
|
#[ORM\Column(length: 50, nullable: true)] |
37
|
|
|
protected ?string $type; |
38
|
|
|
|
39
|
|
|
#[ORM\Column(nullable: false)] |
40
|
|
|
protected int $viewerCount; |
41
|
|
|
|
42
|
|
|
#[ORM\Column(length: 10, nullable: false)] |
43
|
|
|
protected string $language; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var array<string> |
47
|
|
|
*/ |
48
|
|
|
#[ORM\Column(type: 'array', nullable: false)] |
49
|
|
|
private array $tags = []; |
50
|
|
|
|
51
|
|
|
private bool $isMature = false; |
52
|
|
|
|
53
|
|
|
public function getGame(): ?Game |
54
|
|
|
{ |
55
|
|
|
return $this->game; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function setGame(?Game $game): void |
59
|
|
|
{ |
60
|
|
|
$this->game = $game; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getId(): ?int |
64
|
|
|
{ |
65
|
|
|
return $this->id; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function setId(?int $id): void |
69
|
|
|
{ |
70
|
|
|
$this->id = $id; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getExternalId(): string |
74
|
|
|
{ |
75
|
|
|
return $this->externalId; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function setExternalId(string $externalId): void |
79
|
|
|
{ |
80
|
|
|
$this->externalId = $externalId; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getChannel(): Channel |
84
|
|
|
{ |
85
|
|
|
return $this->channel; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function setChannel(Channel $channel): void |
89
|
|
|
{ |
90
|
|
|
$this->channel = $channel; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getStartedAt(): ?\DateTime |
94
|
|
|
{ |
95
|
|
|
return $this->startedAt; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function setStartedAt(?\DateTime $startedAt): void |
99
|
|
|
{ |
100
|
|
|
$this->startedAt = $startedAt; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function getTitle(): string |
104
|
|
|
{ |
105
|
|
|
return $this->title; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function setTitle(string $title): void |
109
|
|
|
{ |
110
|
|
|
$this->title = $title; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function getType(): ?string |
114
|
|
|
{ |
115
|
|
|
return $this->type; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function setType(?string $type): void |
119
|
|
|
{ |
120
|
|
|
$this->type = $type; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function getViewerCount(): int |
124
|
|
|
{ |
125
|
|
|
return $this->viewerCount; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function setViewerCount(int $viewerCount): void |
129
|
|
|
{ |
130
|
|
|
$this->viewerCount = $viewerCount; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function getLanguage(): string |
134
|
|
|
{ |
135
|
|
|
return $this->language; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function setLanguage(string $language): void |
139
|
|
|
{ |
140
|
|
|
$this->language = $language; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function getTags(): array |
144
|
|
|
{ |
145
|
|
|
return $this->tags; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function setTags(array $tags): void |
149
|
|
|
{ |
150
|
|
|
$this->tags = $tags; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function isMature(): bool |
154
|
|
|
{ |
155
|
|
|
return $this->isMature; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function setIsMature(bool $isMature): void |
159
|
|
|
{ |
160
|
|
|
$this->isMature = $isMature; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
public function __toString(): string |
164
|
|
|
{ |
165
|
|
|
return sprintf('Stream [%d]', $this->id); |
166
|
|
|
} |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
|