Skip to content

Commit 15b49ac

Browse files
authored
Merge pull request #9 from attogram/v2
cleanups
2 parents b0cb3ab + 9382862 commit 15b49ac

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

public/example.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Example of using the Weatherbit API Wrapper
4-
*
4+
*
55
* @see https://github.com/attogram/weatherbit-api-wrapper
66
*/
77
declare(strict_types = 1);
@@ -50,7 +50,6 @@
5050
$weatherbit = new Weatherbit();
5151

5252
try {
53-
5453
$weatherbit->setKey($data['key']);
5554

5655
if (!empty($data['units'] && $data['units'] != 'M')) {
@@ -128,9 +127,10 @@ function printForm()
128127
129128
<dl>
130129
<dt>Location by City:</dt>
131-
<dd> City: <input name="city" type="text" value="' . htmlentities($data['city']) . '" size="20" /></dd>
132-
<dd>Country: <input name="country" type="text" value="' . htmlentities($data['country']) . '" size="2" maxlength="2" />
133-
(2 Letter Country Code) (optional)</dd>
130+
<dd> City: <input name="city" type="text" value="' . htmlentities($data['city'])
131+
. '" size="20" /></dd>
132+
<dd>Country: <input name="country" type="text" value="' . htmlentities($data['country'])
133+
. '" size="2" maxlength="2" /> (2 Letter Country Code) (optional)</dd>
134134
<br />
135135
<dt>Location By Latitude / Longitude:</dt>
136136
<dd>Latitude: <input name="lat" type="text" value="' . $data['latitude'] . '" size="20" /></dd>
@@ -143,17 +143,16 @@ function printForm()
143143
Forecast Days (1-16): <input name="days" type="text" value="' . $data['days'] . '" size="2" maxlength="2" />
144144
<br />
145145
146-
Language: <input name="language" type="text" value="' . htmlentities($data['language']) . '" size="2" maxlength="2" />
147-
(2 Letter Language code)
148-
146+
Language: <input name="language" type="text" value="' . htmlentities($data['language'])
147+
. '" size="2" maxlength="2" /> (2 Letter Language code)
149148
<br />
150149
151150
Units:
152-
<input type="radio" name="units" value="M"' . $data['units_M'] . '>M - Metric (Celcius, m/s, mm)</input>
153-
&nbsp;
154-
<input type="radio" name="units" value="I"' . $data['units_I'] . '>I - Imperial (Fahrenheit, mph, in)</input>
155-
&nbsp;
156-
<input type="radio" name="units" value="S"' . $data['units_S'] . '>S - Scientific (Kelvin, m/s, mm)</input>
151+
<input type="radio" name="units" value="M"' . $data['units_M'] . '>M - Metric (Celcius, m/s, mm)</input>
152+
&nbsp;
153+
<input type="radio" name="units" value="I"' . $data['units_I'] . '>I - Imperial (Fahrenheit, mph, in)</input>
154+
&nbsp;
155+
<input type="radio" name="units" value="S"' . $data['units_S'] . '>S - Scientific (Kelvin, m/s, mm)</input>
157156
</select>
158157
<br />
159158
<br />

src/Weatherbit.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Weatherbit API Wrapper
4-
*
4+
*
55
* @see https://github.com/attogram/weatherbit-api-wrapper
66
*/
77
declare(strict_types = 1);
@@ -21,7 +21,7 @@
2121

2222
class Weatherbit
2323
{
24-
const VERSION = '2.0.0';
24+
const VERSION = '2.0.1';
2525

2626
/**
2727
* @var string - user agent for API requests
@@ -74,7 +74,7 @@ class Weatherbit
7474
private $language = '';
7575

7676
/**
77-
* @var string - Units for API Response
77+
* @var string - Units for API Response
7878
* M = [DEFAULT] Metric (Celcius, m/s, mm)
7979
* S = Scientific (Kelvin, m/s, mm)
8080
* I = Imperial (Fahrenheit, mph, in)
@@ -124,7 +124,7 @@ public function setLanguage(string $languageCode)
124124
/**
125125
* Set Units
126126
* @see https://www.weatherbit.io/api/requests
127-
*
127+
*
128128
* @param string $unitsCode - 1 letter units code
129129
*/
130130
public function setUnits(string $unitsCode)
@@ -137,7 +137,7 @@ public function setUnits(string $unitsCode)
137137

138138
/**
139139
* Set Location by Latitude/Longitude
140-
*
140+
*
141141
* @param string $latitude
142142
* @param string $longitude
143143
*/
@@ -155,7 +155,7 @@ public function setLocationByLatitudeLongitude(string $latitude, string $longitu
155155

156156
/**
157157
* Set Location by City Name
158-
*
158+
*
159159
* @param string $city
160160
* @param string $country (optional) 2 letter country code
161161
*/
@@ -177,7 +177,7 @@ public function setLocationByCity(string $city, string $country = '')
177177

178178
/**
179179
* Set Location by City ID
180-
*
180+
*
181181
* @param string $cityId
182182
*/
183183
public function setLocationByCityId(string $cityId)
@@ -189,7 +189,7 @@ public function setLocationByCityId(string $cityId)
189189

190190
/**
191191
* Set Location to a List of Cities IDs
192-
*
192+
*
193193
* @param array $cityIds
194194
*/
195195
public function setLocationByCityIds(array $cityIds)
@@ -202,7 +202,7 @@ public function setLocationByCityIds(array $cityIds)
202202

203203
/**
204204
* Set Location by Postal Code
205-
*
205+
*
206206
* @param string $postalCode
207207
*/
208208
public function setLocationByPostalCode(string $postalCode)
@@ -214,7 +214,7 @@ public function setLocationByPostalCode(string $postalCode)
214214

215215
/**
216216
* Set Location by IP Address
217-
*
217+
*
218218
* @param string $ipAddress - Ip Address, or 'auto'
219219
*/
220220
public function setLocationByIp(string $ipAddress = 'auto')
@@ -226,7 +226,7 @@ public function setLocationByIp(string $ipAddress = 'auto')
226226

227227
/**
228228
* Set Location by Weather Station
229-
*
229+
*
230230
* @param string $weatherStations
231231
*/
232232
public function setLocationByStation(string $weatherStation)
@@ -238,6 +238,8 @@ public function setLocationByStation(string $weatherStation)
238238

239239
/**
240240
* Set Location to List of Weather Stations
241+
*
242+
* @param array $weatherStations
241243
*/
242244
public function setLocationByStations(array $weatherStations)
243245
{
@@ -260,7 +262,7 @@ public function getDailyForecast($days = 10): array
260262
}
261263

262264
$this->setUrl(
263-
self::POSTFIX_FORECAST_DAILY,
265+
self::POSTFIX_FORECAST_DAILY,
264266
['days' => $days]
265267
);
266268

@@ -294,7 +296,7 @@ public function getUsage(): array
294296

295297
/**
296298
* Get current API Call URL
297-
*
299+
*
298300
* @return string - The Current URL
299301
*/
300302
public function getUrl(): string
@@ -304,7 +306,7 @@ public function getUrl(): string
304306

305307
/**
306308
* Set the URL string for the API Call
307-
*
309+
*
308310
* @param string $prefix - URL Prefix
309311
* @param array $additional - array of name/value pairs for additional URL values
310312
* @throws Exception

tests/WeatherbitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Weatherbits API Wrapper Tests
4-
*
4+
*
55
* @see https://github.com/attogram/weatherbit-api-wrapper
66
*/
77
declare(strict_types=1);

0 commit comments

Comments
 (0)