|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Igorsgm\TibiaDataApi\Models\Worlds; |
|
4
|
|
|
|
|
5
|
|
|
use Igorsgm\TibiaDataApi\Exceptions\ImmutableException; |
|
6
|
|
|
use Igorsgm\TibiaDataApi\Traits\ImmutableTrait; |
|
7
|
|
|
use Igorsgm\TibiaDataApi\Traits\SerializableTrait; |
|
8
|
|
|
|
|
9
|
|
|
class World |
|
10
|
|
|
{ |
|
11
|
|
|
use ImmutableTrait, SerializableTrait; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @var string |
|
15
|
|
|
*/ |
|
16
|
|
|
private $name; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var int |
|
20
|
|
|
*/ |
|
21
|
|
|
private $online; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private $location; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
private $type; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
private $additional; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* World constructor. |
|
40
|
|
|
* @param string $name |
|
41
|
|
|
* @param int $online |
|
42
|
|
|
* @param string $location |
|
43
|
|
|
* @param string $type |
|
44
|
|
|
* @param string $additional |
|
45
|
|
|
* @throws ImmutableException |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct(string $name, int $online, string $location, string $type, string $additional) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->handleImmutableConstructor(); |
|
50
|
|
|
|
|
51
|
|
|
$this->name = $name; |
|
52
|
|
|
$this->online = $online; |
|
53
|
|
|
$this->location = $location; |
|
54
|
|
|
$this->type = $type; |
|
55
|
|
|
$this->additional = $additional; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @return string |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getName(): string |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->name; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return int |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getOnline(): int |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->online; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return string |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getLocation(): string |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->location; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return string |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getType(): string |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->type; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @return string |
|
92
|
|
|
*/ |
|
93
|
|
|
public function getAdditional(): string |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->additional; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @return bool |
|
100
|
|
|
*/ |
|
101
|
|
|
public function isBlocked(): bool |
|
102
|
|
|
{ |
|
103
|
|
|
return strpos($this->additional, 'blocked') !== false; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return bool |
|
108
|
|
|
*/ |
|
109
|
|
|
public function isPremium(): bool |
|
110
|
|
|
{ |
|
111
|
|
|
return strpos($this->additional, 'premium') !== false; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @return bool |
|
116
|
|
|
*/ |
|
117
|
|
|
public function isLocked(): bool |
|
118
|
|
|
{ |
|
119
|
|
|
return (bool) preg_match('/\blocked\b/', $this->additional); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return bool |
|
124
|
|
|
*/ |
|
125
|
|
|
public function isExperimental(): bool |
|
126
|
|
|
{ |
|
127
|
|
|
return strpos($this->additional, 'experimental game world') !== false; |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|