Skip to content

Commit 8f45323

Browse files
committed
docs: fixed typos and some improvements
1 parent 514fb63 commit 8f45323

File tree

5 files changed

+36
-35
lines changed

5 files changed

+36
-35
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ echo $weather->getTemperature();
4747
- [Configuration](docs/02-configuration.md)
4848
- [Supported APIs](docs/03-supported-apis.md)
4949
- [Error Handling](docs/04-error-handling.md)
50-
- [Entities](docs/05-entities)
50+
- [Entities](docs/05-entities.md)
5151

5252
## Contributing
5353

docs/02-configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Example:
3131
use ProgrammatorDev\OpenWeatherMap\UnitSystem\UnitSystem;
3232
use ProgrammatorDev\OpenWeatherMap\OpenWeatherMap;
3333

34-
$api = new OpenWeatherMap('yourapikey',
34+
$api = new OpenWeatherMap('yourapikey', [
3535
'unitSystem' => UnitSystem::IMPERIAL
3636
]);
3737
```
@@ -49,7 +49,7 @@ Example:
4949
use ProgrammatorDev\OpenWeatherMap\Language\Language;
5050
use ProgrammatorDev\OpenWeatherMap\OpenWeatherMap;
5151

52-
$api = new OpenWeatherMap('yourapikey',
52+
$api = new OpenWeatherMap('yourapikey', [
5353
'language' => Language::PORTUGUESE
5454
]);
5555
```

docs/03-supported-apis.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ getWeather(float $latitude, float $longitude): OneCall
3333

3434
Get current and forecast (minutely, hourly and daily) weather data.
3535

36-
Returns a [`OneCall`](05-entities#onecall) object:
36+
Returns a [`OneCall`](05-entities.md#onecall) object:
3737

3838
```php
3939
$weather = $openWeatherMap->oneCall()->getWeather(50, 50);
@@ -49,7 +49,7 @@ getHistoryMoment(float $latitude, float $longitude, \DateTimeInterface $dateTime
4949

5050
Get weather data from a single moment in the past.
5151

52-
Returns a [`WeatherLocation`](05-entities#weatherlocation) object:
52+
Returns a [`WeatherLocation`](05-entities.md#weatherlocation) object:
5353

5454
```php
5555
$weather = $openWeatherMap->oneCall()->getHistoryMoment(50, 50, new \DateTime('2023-01-01 12:00:00'));
@@ -65,7 +65,7 @@ getHistoryAggregate(float $latitude, float $longitude, \DateTimeInterface $date)
6565

6666
Get aggregated weather data from a single day in the past.
6767

68-
Returns a [`WeatherAggregate`](05-entities#weatheraggregate) object:
68+
Returns a [`WeatherAggregate`](05-entities.md#weatheraggregate) object:
6969

7070
```php
7171
$weather = $openWeatherMap->oneCall()->getHistoryAggregate(50, 50, new \DateTime('1985-07-19'));
@@ -83,7 +83,7 @@ getCurrent(float $latitude, float $longitude): WeatherLocation
8383

8484
Get current weather data.
8585

86-
Returns a [`WeatherLocation`](05-entities#weatherlocation-1) object:
86+
Returns a [`WeatherLocation`](05-entities.md#weatherlocation-1) object:
8787

8888
```php
8989
$weather = $openWeatherMap->weather()->getCurrent(50, 50);
@@ -99,7 +99,7 @@ getForecast(float $latitude, float $longitude, int $numResults = 40): WeatherLoc
9999

100100
Get weather forecast data per 3-hour steps for the next 5 days.
101101

102-
Returns a [`WeatherLocationList`](05-entities#weatherlocationlist) object:
102+
Returns a [`WeatherLocationList`](05-entities.md#weatherlocationlist) object:
103103

104104
```php
105105
// Since it returns 3-hour steps,
@@ -122,7 +122,7 @@ getCurrent(float $latitude, float $longitude): AirPollutionLocation
122122

123123
Get current air pollution data.
124124

125-
Returns a [`AirPollutionLocation`](05-entities#airpollutionlocation) object:
125+
Returns a [`AirPollutionLocation`](05-entities.md#airpollutionlocation) object:
126126

127127
```php
128128
$airPollution = $openWeatherMap->airPollution()->getCurrent(50, 50);
@@ -139,7 +139,7 @@ getForecast(float $latitude, float $longitude): AirPollutionLocationList
139139

140140
Get air pollution forecast data per 1-hour for the next 24 hours.
141141

142-
Returns a [`AirPollutionLocationList`](05-entities#airpollutionlocationlist) object:
142+
Returns a [`AirPollutionLocationList`](05-entities.md#airpollutionlocationlist) object:
143143

144144
```php
145145
$airPollutionForecast = $openWeatherMap->airPollution()->getForecast(50, 50);
@@ -159,7 +159,7 @@ getHistory(float $latitude, float $longitude, \DateTimeInterface $startDate, \Da
159159

160160
Get air pollution history data between two dates.
161161

162-
Returns a [`AirPollutionLocationList`](05-entities#airpollutionlocationlist) object:
162+
Returns a [`AirPollutionLocationList`](05-entities.md#airpollutionlocationlist) object:
163163

164164
```php
165165
$startDate = new \DateTime('-7 days'); // 7 days ago
@@ -177,7 +177,7 @@ foreach ($airPollutionHistory->getList() as $airPollution) {
177177

178178
#### `getByLocationName`
179179

180-
Get locations by location name. Returns an array of [`Location`](05-entities#location) entities:
180+
Get locations by location name. Returns an array of [`Location`](05-entities.md#location) entities:
181181

182182
```php
183183
/**
@@ -192,7 +192,7 @@ $api->geocoding()->getByLocationName('lisbon');
192192

193193
#### `getByCoordinate`
194194

195-
Get locations by coordinate. Returns an array of [`Location`](05-entities#location) entities:
195+
Get locations by coordinate. Returns an array of [`Location`](05-entities.md#location) entities:
196196

197197
```php
198198
/**
@@ -207,7 +207,7 @@ $api->geocoding()->getByCoordinate(50, 50);
207207

208208
#### `getByZipCode`
209209

210-
Get location by zip code. Returns a [`Location`](05-entities#location) entity:
210+
Get location by zip code. Returns a [`Location`](05-entities.md#location) entity:
211211

212212
```php
213213
getByZipCode(string $zipCode, string $countryCode): Location

docs/04-error-handling.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,36 @@ use ProgrammatorDev\OpenWeatherMap\Exception\UnauthorizedException;
1515
use ProgrammatorDev\OpenWeatherMap\Exception\UnexpectedErrorException;
1616

1717
try {
18-
$location = $openWeatherMap->geocoding()->getByZipCode('1000-001', 'pt');
18+
$location = $api->geocoding()->getByZipCode('1000-001', 'pt');
19+
$coordinate = $location->getCoordinate();
1920

20-
$weather = $openWeatherMap->oneCall()->getWeather(
21-
$location->getCoordinate()->getLatitude(),
22-
$location->getCoordinate()->getLongitude()
21+
$weather = $api->oneCall()->getWeather(
22+
$coordinate->getLatitude(),
23+
$coordinate->getLongitude()
2324
);
2425
}
25-
// Bad requests to the API
26-
// If this library is making a good job validating input data, this should not happen
26+
// bad request to the api
2727
catch (BadRequestException $exception) {
2828
echo $exception->getCode(); // 400
2929
echo $exception->getMessage();
3030
}
31-
// Invalid API key or trying to request an endpoint with no granted access
31+
// invalid API key or trying to request an endpoint with no granted access
3232
catch (UnauthorizedException $exception) {
3333
echo $exception->getCode(); // 401
3434
echo $exception->getMessage();
3535
}
36-
// Resource not found
37-
// For example, when trying to get a location with a zip/post code that does not exist
36+
// resource not found
37+
// for example, when trying to get a location with a zip code that does not exist
3838
catch (NotFoundException $exception) {
3939
echo $exception->getCode(); // 404
4040
echo $exception->getMessage();
4141
}
42-
// API key requests quota exceeded
42+
// api key requests quota exceeded
4343
catch (TooManyRequestsException $exception) {
4444
echo $exception->getCode(); // 429
4545
echo $exception->getMessage();
4646
}
47-
// Any other error, probably an internal error
47+
// any other error, probably an internal error
4848
catch (UnexpectedErrorException $exception) {
4949
echo $exception->getCode(); // 5xx
5050
echo $exception->getMessage();
@@ -57,14 +57,15 @@ To catch all API errors with a single exception, `ApiErrorException` is availabl
5757
use ProgrammatorDev\OpenWeatherMap\Exception\ApiErrorException;
5858

5959
try {
60-
$location = $openWeatherMap->geocoding()->getByZipCode('1000-001', 'pt');
60+
$location = $api->geocoding()->getByZipCode('1000-001', 'pt');
61+
$coordinate = $location->getCoordinate();
6162

62-
$weather = $openWeatherMap->oneCall()->getWeather(
63-
$location->getCoordinate()->getLatitude(),
64-
$location->getCoordinate()->getLongitude()
63+
$weather = $api->oneCall()->getWeather(
64+
$coordinate->getLatitude(),
65+
$coordinate->getLongitude()
6566
);
6667
}
67-
// Catches all API response errors
68+
// catches all api response errors
6869
catch (ApiErrorException $exception) {
6970
echo $exception->getCode();
7071
echo $exception->getMessage();
@@ -76,14 +77,14 @@ catch (ApiErrorException $exception) {
7677
To catch invalid input data (like an out of range coordinate, blank location name, etc.), the `ValidationException` is available:
7778

7879
```php
79-
use ProgrammatorDev\YetAnotherPhpValidator\Exception\ValidationException;
80+
use ProgrammatorDev\Validator\Exception\ValidationException;
8081

8182
try {
82-
// An invalid latitude value is given
83-
$weather = $openWeatherMap->weather()->getCurrent(999, 50);
83+
// an invalid latitude value is given
84+
$weather = $api->weather()->getCurrent(999, 50);
8485
}
8586
catch (ValidationException $exception) {
86-
// Should print:
87+
// should print:
8788
// The latitude value should be between -90 and 90, 999 given.
8889
echo $exception->getMessage();
8990
}

docs/05-entities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,12 @@
217217

218218
### Location
219219

220-
- `getId()`: `?int`
221220
- `getName()`: `?string`
222221
- `getState()`: `?string`
223222
- `getCountryCode()`: `?string`
224223
- `getLocalNames()`: `?array`
225224
- `getLocalName(string $countryCode)`: `?string`
225+
- `getZipCode()`: `?string`
226226
- `getCoordinate()`: [`Coordinate`](#coordinate)
227227

228228
### MoonPhase

0 commit comments

Comments
 (0)