Skip to content

Commit ea1f472

Browse files
committed
Make location data nullable for error responses
1 parent 16f7808 commit ea1f472

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

src/Dto/LocationDto.php

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ class LocationDto
1111
protected $status;
1212

1313
/**
14-
* @var string
14+
* @var string|null
1515
*/
1616
protected $latitude;
1717

1818
/**
19-
* @var string
19+
* @var string|null
2020
*/
2121
protected $longitude;
2222

2323
/**
24-
* @var string
24+
* @var string|null
2525
*/
2626
protected $timezone;
2727

2828
/**
29-
* @var string
29+
* @var string|null
3030
*/
3131
protected $region;
3232

3333
/**
34-
* @var string
34+
* @var string|null
3535
*/
3636
protected $country;
3737

3838
/**
39-
* @var string
39+
* @var string|null
4040
*/
4141
protected $city;
4242

@@ -47,22 +47,22 @@ class LocationDto
4747

4848
/**
4949
* @param string $status
50-
* @param string $latitude
51-
* @param string $longitude
52-
* @param string $timezone
53-
* @param string $region
54-
* @param string $country
55-
* @param string $city
50+
* @param string|null $latitude
51+
* @param string|null $longitude
52+
* @param string|null $timezone
53+
* @param string|null $region
54+
* @param string|null $country
55+
* @param string|null $city
5656
* @param string $message
5757
*/
5858
public function __construct(
5959
string $status,
60-
string $latitude,
61-
string $longitude,
62-
string $timezone,
63-
string $region,
64-
string $country,
65-
string $city,
60+
?string $latitude,
61+
?string $longitude,
62+
?string $timezone,
63+
?string $region,
64+
?string $country,
65+
?string $city,
6666
string $message
6767
) {
6868
$this->setStatus($status)
@@ -96,119 +96,119 @@ public function setStatus(string $status): LocationDto
9696
}
9797

9898
/**
99-
* @return string
99+
* @return string|null
100100
*/
101-
public function getLatitude(): string
101+
public function getLatitude(): ?string
102102
{
103103
return $this->latitude;
104104
}
105105

106106
/**
107-
* @param string $latitude
107+
* @param string|null $latitude
108108
*
109109
* @return LocationDto
110110
*/
111-
public function setLatitude(string $latitude): LocationDto
111+
public function setLatitude(?string $latitude): LocationDto
112112
{
113113
$this->latitude = $latitude;
114114

115115
return $this;
116116
}
117117

118118
/**
119-
* @return string
119+
* @return string|null
120120
*/
121-
public function getLongitude(): string
121+
public function getLongitude(): ?string
122122
{
123123
return $this->longitude;
124124
}
125125

126126
/**
127-
* @param string $longitude
127+
* @param string|null $longitude
128128
*
129129
* @return LocationDto
130130
*/
131-
public function setLongitude(string $longitude): LocationDto
131+
public function setLongitude(?string $longitude): LocationDto
132132
{
133133
$this->longitude = $longitude;
134134

135135
return $this;
136136
}
137137

138138
/**
139-
* @return string
139+
* @return string|null
140140
*/
141-
public function getTimezone(): string
141+
public function getTimezone(): ?string
142142
{
143143
return $this->timezone;
144144
}
145145

146146
/**
147-
* @param string $timezone
147+
* @param string|null $timezone
148148
*
149149
* @return LocationDto
150150
*/
151-
public function setTimezone(string $timezone): LocationDto
151+
public function setTimezone(?string $timezone): LocationDto
152152
{
153153
$this->timezone = $timezone;
154154

155155
return $this;
156156
}
157157

158158
/**
159-
* @return string
159+
* @return string|null
160160
*/
161-
public function getRegion(): string
161+
public function getRegion(): ?string
162162
{
163163
return $this->region;
164164
}
165165

166166
/**
167-
* @param string $region
167+
* @param string|null $region
168168
*
169169
* @return LocationDto
170170
*/
171-
public function setRegion(string $region): LocationDto
171+
public function setRegion(?string $region): LocationDto
172172
{
173173
$this->region = $region;
174174

175175
return $this;
176176
}
177177

178178
/**
179-
* @return string
179+
* @return string|null
180180
*/
181-
public function getCountry(): string
181+
public function getCountry(): ?string
182182
{
183183
return $this->country;
184184
}
185185

186186
/**
187-
* @param string $country
187+
* @param string|null $country
188188
*
189189
* @return LocationDto
190190
*/
191-
public function setCountry(string $country): LocationDto
191+
public function setCountry(?string $country): LocationDto
192192
{
193193
$this->country = $country;
194194

195195
return $this;
196196
}
197197

198198
/**
199-
* @return string
199+
* @return string|null
200200
*/
201-
public function getCity(): string
201+
public function getCity(): ?string
202202
{
203203
return $this->city;
204204
}
205205

206206
/**
207-
* @param string $city
207+
* @param string|null $city
208208
*
209209
* @return LocationDto
210210
*/
211-
public function setCity(string $city): LocationDto
211+
public function setCity(?string $city): LocationDto
212212
{
213213
$this->city = $city;
214214

@@ -244,12 +244,12 @@ public static function fromArray(array $locationData): self
244244
{
245245
return new self(
246246
$locationData['status'],
247-
(string)$locationData['lat'],
248-
(string)$locationData['lon'],
249-
$locationData['timezone'],
250-
$locationData['region'],
251-
$locationData['country'],
252-
$locationData['city'],
247+
(string)$locationData['lat'] ?? null,
248+
(string)$locationData['lon'] ?? null,
249+
$locationData['timezone'] ?? null,
250+
$locationData['region'] ?? null,
251+
$locationData['country'] ?? null,
252+
$locationData['city'] ?? null,
253253
$locationData['message']
254254
);
255255
}

0 commit comments

Comments
 (0)