1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of SteamScore. |
7
|
|
|
* |
8
|
|
|
* (c) SteamScore <[email protected]> |
9
|
|
|
* |
10
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public |
11
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this |
12
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace SteamScore\Api\Domain\Entities; |
16
|
|
|
|
17
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
18
|
|
|
use Doctrine\Common\Collections\Collection; |
19
|
|
|
use Ramsey\Uuid\Uuid; |
20
|
|
|
use Ramsey\Uuid\UuidInterface; |
21
|
|
|
|
22
|
|
|
final class Game |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var Collection |
26
|
|
|
*/ |
27
|
|
|
private $achievements; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var int |
31
|
|
|
*/ |
32
|
|
|
private $appId; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string|null |
36
|
|
|
*/ |
37
|
|
|
private $developer; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var UuidInterface |
41
|
|
|
*/ |
42
|
|
|
private $id; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
private $name; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var int |
51
|
|
|
*/ |
52
|
|
|
private $players; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var string|null |
56
|
|
|
*/ |
57
|
|
|
private $publisher; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var int|null |
61
|
|
|
*/ |
62
|
|
|
private $scoreRank; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Constructor. |
66
|
|
|
* |
67
|
|
|
* @param int $appId |
68
|
|
|
* @param string $name |
69
|
|
|
* @param string|null $developer |
70
|
|
|
* @param string|null $publisher |
71
|
|
|
* @param int|null $scoreRank |
72
|
|
|
* @param int $players |
73
|
|
|
*/ |
74
|
|
|
public function __construct( |
75
|
|
|
int $appId, |
76
|
|
|
string $name, |
77
|
|
|
?string $developer, |
78
|
|
|
?string $publisher, |
79
|
|
|
?int $scoreRank, |
80
|
|
|
int $players |
81
|
|
|
) { |
82
|
|
|
$this->achievements = new ArrayCollection(); |
83
|
|
|
$this->appId = $appId; |
84
|
|
|
$this->developer = $developer; |
85
|
|
|
$this->id = Uuid::uuid4(); |
86
|
|
|
$this->name = $name; |
87
|
|
|
$this->players = $players; |
88
|
|
|
$this->publisher = $publisher; |
89
|
|
|
$this->scoreRank = $scoreRank; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Gets all achievements that belongs to the game. |
94
|
|
|
* |
95
|
|
|
* @return Collection |
96
|
|
|
*/ |
97
|
1 |
|
public function getAchievements(): Collection |
98
|
|
|
{ |
99
|
1 |
|
return $this->achievements; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Gets the unique Steam identifier. |
104
|
|
|
* |
105
|
|
|
* @return int |
106
|
|
|
*/ |
107
|
|
|
public function getAppId(): int |
108
|
|
|
{ |
109
|
|
|
return $this->appId; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Gets the developer of the game. |
114
|
|
|
* |
115
|
|
|
* @return string |
116
|
|
|
*/ |
117
|
|
|
public function getDeveloper(): string |
118
|
|
|
{ |
119
|
|
|
return $this->developer; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Gets the unique identifier. |
124
|
|
|
* |
125
|
|
|
* @return UuidInterface |
126
|
|
|
*/ |
127
|
1 |
|
public function getId(): UuidInterface |
128
|
|
|
{ |
129
|
1 |
|
return $this->id; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Gets the name of the game. |
134
|
|
|
* |
135
|
|
|
* @return string |
136
|
|
|
*/ |
137
|
|
|
public function getName(): string |
138
|
|
|
{ |
139
|
|
|
return $this->name; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Gets the number of people that owns the game. |
144
|
|
|
* |
145
|
|
|
* @return int |
146
|
|
|
*/ |
147
|
|
|
public function getPlayers(): int |
148
|
|
|
{ |
149
|
|
|
return $this->owners; |
|
|
|
|
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Gets the publisher of the game. |
154
|
|
|
* |
155
|
|
|
* @return string |
156
|
|
|
*/ |
157
|
|
|
public function getPublisher(): string |
158
|
|
|
{ |
159
|
|
|
return $this->publisher; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Gets the score rank of the game. |
164
|
|
|
* |
165
|
|
|
* @return int |
166
|
|
|
*/ |
167
|
|
|
public function getScoreRank(): int |
168
|
|
|
{ |
169
|
|
|
return $this->scoreRank; |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: