1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace Nelexa\GPlay\Model; |
5
|
|
|
|
6
|
|
|
use Nelexa\GPlay\Model\Builder\DeveloperBuilder; |
7
|
|
|
|
8
|
|
|
class Developer |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var string |
12
|
|
|
*/ |
13
|
|
|
private $id; |
14
|
|
|
/** |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
private $url; |
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
private $name; |
22
|
|
|
/** |
23
|
|
|
* @var string|null |
24
|
|
|
*/ |
25
|
|
|
private $description; |
26
|
|
|
/** |
27
|
|
|
* @var string|null |
28
|
|
|
*/ |
29
|
|
|
private $website; |
30
|
|
|
/** |
31
|
|
|
* @var GoogleImage|null |
32
|
|
|
*/ |
33
|
|
|
private $icon; |
34
|
|
|
/** |
35
|
|
|
* @var GoogleImage|null |
36
|
|
|
*/ |
37
|
|
|
private $headerImage; |
38
|
|
|
/** |
39
|
|
|
* @var string|null |
40
|
|
|
*/ |
41
|
|
|
private $email; |
42
|
|
|
/** |
43
|
|
|
* @var string|null |
44
|
|
|
*/ |
45
|
|
|
private $address; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return DeveloperBuilder |
49
|
|
|
*/ |
50
|
|
|
public static function newBuilder(): DeveloperBuilder |
51
|
|
|
{ |
52
|
|
|
return new DeveloperBuilder(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Developer constructor. |
57
|
|
|
* |
58
|
|
|
* @param DeveloperBuilder $builder |
59
|
|
|
*/ |
60
|
|
|
public function __construct(DeveloperBuilder $builder) |
61
|
|
|
{ |
62
|
|
|
$this->id = $builder->getId(); |
63
|
|
|
$this->url = $builder->getUrl(); |
64
|
|
|
$this->name = $builder->getName(); |
65
|
|
|
$this->description = $builder->getDescription(); |
66
|
|
|
$this->website = $builder->getWebsite(); |
67
|
|
|
$this->icon = $builder->getIcon(); |
68
|
|
|
$this->headerImage = $builder->getHeaderImage(); |
69
|
|
|
$this->email = $builder->getEmail(); |
70
|
|
|
$this->address = $builder->getAddress(); |
71
|
|
|
|
72
|
|
|
if (empty($this->id)) { |
73
|
|
|
throw new \InvalidArgumentException('$id cannot be null or empty. Solution: $developerBuilder->setId(...);'); |
74
|
|
|
} |
75
|
|
|
if (empty($this->url)) { |
76
|
|
|
throw new \InvalidArgumentException('$url cannot be null or empty. Solution: $developerBuilder->setUrl(...);'); |
77
|
|
|
} |
78
|
|
|
if (empty($this->name)) { |
79
|
|
|
throw new \InvalidArgumentException('$name cannot be null or empty. Solution: $developerBuilder->setName(...);'); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return string |
85
|
|
|
*/ |
86
|
|
|
public function getId(): string |
87
|
|
|
{ |
88
|
|
|
return $this->id; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getUrl(): string |
95
|
|
|
{ |
96
|
|
|
return $this->url; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return string |
101
|
|
|
*/ |
102
|
|
|
public function getName(): string |
103
|
|
|
{ |
104
|
|
|
return $this->name; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return string|null |
109
|
|
|
*/ |
110
|
|
|
public function getDescription(): ?string |
111
|
|
|
{ |
112
|
|
|
return $this->description; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return string|null |
117
|
|
|
*/ |
118
|
|
|
public function getWebsite(): ?string |
119
|
|
|
{ |
120
|
|
|
return $this->website; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return GoogleImage|null |
125
|
|
|
*/ |
126
|
|
|
public function getIcon(): ?GoogleImage |
127
|
|
|
{ |
128
|
|
|
return $this->icon; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return GoogleImage|null |
133
|
|
|
*/ |
134
|
|
|
public function getHeaderImage(): ?GoogleImage |
135
|
|
|
{ |
136
|
|
|
return $this->headerImage; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return string|null |
141
|
|
|
*/ |
142
|
|
|
public function getEmail(): ?string |
143
|
|
|
{ |
144
|
|
|
return $this->email; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return string|null |
149
|
|
|
*/ |
150
|
|
|
public function getAddress(): ?string |
151
|
|
|
{ |
152
|
|
|
return $this->address; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param Developer $o |
157
|
|
|
* @return bool |
158
|
|
|
*/ |
159
|
|
|
public function equals(Developer $o): bool |
160
|
|
|
{ |
161
|
|
|
if ($this->id !== $o->id) { |
162
|
|
|
return false; |
163
|
|
|
} |
164
|
|
|
if ($this->name !== $o->name) { |
165
|
|
|
return false; |
166
|
|
|
} |
167
|
|
|
if ($this->description !== $o->description) { |
168
|
|
|
return false; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
if ($this->icon !== null && $o->icon !== null) { |
172
|
|
|
if ($this->icon->getUrl() !== $o->icon->getUrl()) { |
173
|
|
|
return false; |
174
|
|
|
} |
175
|
|
|
} elseif ($this->icon !== $o->icon) { |
176
|
|
|
return false; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
if ($this->headerImage !== null && $o->headerImage !== null) { |
180
|
|
|
if ($this->headerImage->getUrl() !== $o->headerImage->getUrl()) { |
181
|
|
|
return false; |
182
|
|
|
} |
183
|
|
|
} elseif ($this->headerImage !== $o->headerImage) { |
184
|
|
|
return false; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
return true; |
188
|
|
|
} |
189
|
|
|
} |
190
|
|
|
|