Total Complexity | 6 |
Total Lines | 64 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
6 | class ProfileInfo { |
||
7 | |||
8 | /** |
||
9 | * @var string |
||
10 | */ |
||
11 | private $id; |
||
12 | |||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | private $name; |
||
17 | |||
18 | /** |
||
19 | * @var bool |
||
20 | */ |
||
21 | private $isLegacy; |
||
22 | |||
23 | /** |
||
24 | * @var bool |
||
25 | */ |
||
26 | private $isDemo; |
||
27 | |||
28 | 6 | public function __construct(string $id, string $name, bool $isLegacy = false, bool $isDemo = false) { |
|
29 | 6 | $this->id = $id; |
|
30 | 6 | $this->name = $name; |
|
31 | 6 | $this->isLegacy = $isLegacy; |
|
32 | 6 | $this->isDemo = $isDemo; |
|
33 | 6 | } |
|
34 | |||
35 | 6 | public static function createFromResponse(array $response): self { |
|
36 | 6 | return new static( |
|
37 | 6 | $response['id'], |
|
38 | 6 | $response['name'], |
|
39 | 6 | $response['legacy'] ?? false, |
|
40 | 6 | $response['demo'] ?? false |
|
41 | ); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return string user's uuid without dashes |
||
46 | */ |
||
47 | 5 | public function getId(): string { |
|
48 | 5 | return $this->id; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return string username at the current time |
||
53 | */ |
||
54 | 4 | public function getName(): string { |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return bool true means, that account not migrated into Mojang account |
||
60 | */ |
||
61 | 4 | public function isLegacy(): bool { |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return bool true means, that account now in demo mode (not premium user) |
||
67 | */ |
||
68 | 4 | public function isDemo(): bool { |
|
70 | } |
||
71 | |||
73 |