Skip to content

Commit d7448de

Browse files
committed
setUrlLocation, setUrlAdditional
1 parent 22e8adf commit d7448de

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/Weatherbit.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,35 @@ private function setUrl($prefix, $additional = [])
333333
if (!empty($this->units)) {
334334
$this->url .= '&units=' . urlencode($this->units);
335335
}
336+
$this->setUrlLocation();
337+
$this->setUrlAdditional($additional);
338+
}
339+
340+
/**
341+
* Set location values to url
342+
*
343+
* @return void
344+
*/
345+
private function setUrlLocation()
346+
{
347+
if (empty($this->location)) {
348+
return;
349+
}
336350
foreach ($this->location as $name => $value) {
337351
if (!empty($value)) {
338352
$this->url .= '&' . $name . '=' . urlencode((string) $value);
339353
}
340354
}
341-
355+
}
356+
357+
/**
358+
* Set additional values to url
359+
*
360+
* @param array $additional
361+
* @return void
362+
*/
363+
private function setUrlAdditional(array $additional = [])
364+
{
342365
if (empty($additional)) {
343366
return;
344367
}
@@ -370,7 +393,9 @@ private function get()
370393
curl_close($curl);
371394

372395
if ($status != '200') {
373-
throw new WeatherbitException('API Failure - status code: ' . $status . ' - data: ' . print_r($jsonData, true));
396+
throw new WeatherbitException(
397+
'API Failure - status code: ' . $status . ' - data: ' . print_r($jsonData, true)
398+
);
374399
}
375400

376401
if (empty($jsonData)) {

0 commit comments

Comments
 (0)