Skip to content

Commit 43a079d

Browse files
committed
chore: updated documentation
1 parent 8abc825 commit 43a079d

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

docs/01-usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ $openWeatherMap = new OpenWeatherMap(
4444
);
4545

4646
// Get current weather by coordinate (latitude, longitude)
47-
$currentWeather = $openWeatherMap->getWeather()->getCurrent(50, 50);
47+
$currentWeather = $openWeatherMap->weather->getCurrent(50, 50);
4848
// Show current temperature
4949
echo $currentWeather->getTemperature();
5050
```

docs/02-configuration.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ It is possible to change the cache duration per request:
187187

188188
```php
189189
// Response will be cached for 1 hour
190-
$currentWeather = $openWeatherMap->getWeather()
190+
$currentWeather = $openWeatherMap->weather
191191
->withCacheTtl(3600)
192192
->getCurrent(50, 50);
193193
```
@@ -244,20 +244,20 @@ $openWeatherMap = new OpenWeatherMap(
244244

245245
// Using applicationKey as an example,
246246
// but getters and setters are available for all options
247-
$openWeatherMap->getConfig()->getApplicationKey();
248-
$openWeatherMap->getConfig()->setApplicationKey('newappkey');
247+
$openWeatherMap->config->getApplicationKey();
248+
$openWeatherMap->config->setApplicationKey('newappkey');
249249
```
250250

251251
Just take into account that any change will affect any subsequent request globally:
252252

253253
```php
254254
// Using default 'metric' unit system
255-
$openWeatherMap->getWeather()->getCurrent(50, 50);
255+
$openWeatherMap->weather->getCurrent(50, 50);
256256

257257
// Set new unit system
258-
$openWeatherMap->getConfig()->setUnitSystem(UnitSystem::IMPERIAL);
258+
$openWeatherMap->config->setUnitSystem(UnitSystem::IMPERIAL);
259259

260260
// Using 'imperial' unit system
261-
$openWeatherMap->getWeather()->getCurrent(50, 50);
262-
$openWeatherMap->getWeather()->getForecast(50, 50);
261+
$openWeatherMap->weather->getCurrent(50, 50);
262+
$openWeatherMap->weather->getForecast(50, 50);
263263
```

docs/03-supported-apis.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Get current and forecast (minutely, hourly and daily) weather data.
3636
Returns a [`OneCall`](05-objects.md#onecall) object:
3737

3838
```php
39-
$weather = $openWeatherMap->getOneCall()->getWeather(50, 50);
39+
$weather = $openWeatherMap->oneCall->getWeather(50, 50);
4040

4141
echo $weather->getCurrent()->getTemperature();
4242
```
@@ -52,7 +52,7 @@ Get weather data from a single moment in the past.
5252
Returns a [`WeatherLocation`](05-objects.md#weatherlocation) object:
5353

5454
```php
55-
$weather = $openWeatherMap->getOneCall()->getHistoryMoment(50, 50, new \DateTime('2023-01-01 12:00:00'));
55+
$weather = $openWeatherMap->oneCall->getHistoryMoment(50, 50, new \DateTime('2023-01-01 12:00:00'));
5656

5757
echo $weather->getTemperature();
5858
```
@@ -68,7 +68,7 @@ Get aggregated weather data from a single day in the past.
6868
Returns a [`WeatherAggregate`](05-objects.md#weatheraggregate) object:
6969

7070
```php
71-
$weather = $openWeatherMap->getOneCall()->getHistoryAggregate(50, 50, new \DateTime('1985-07-19'));
71+
$weather = $openWeatherMap->oneCall->getHistoryAggregate(50, 50, new \DateTime('1985-07-19'));
7272

7373
echo $weather->getTemperature();
7474
```
@@ -86,7 +86,7 @@ Get current weather data.
8686
Returns a [`WeatherLocation`](05-objects.md#weatherlocation-1) object:
8787

8888
```php
89-
$weather = $openWeatherMap->getWeather()->getCurrent(50, 50);
89+
$weather = $openWeatherMap->weather->getCurrent(50, 50);
9090

9191
echo $weather->getTemperature();
9292
```
@@ -104,7 +104,7 @@ Returns a [`WeatherLocationList`](05-objects.md#weatherlocationlist) object:
104104
```php
105105
// Since it returns 3-hour steps,
106106
// passing 8 as the numResults means it will return results for the next 24 hours
107-
$weatherForecast = $openWeatherMap->getWeather()->getForecast(50, 50, 8);
107+
$weatherForecast = $openWeatherMap->weather->getForecast(50, 50, 8);
108108

109109
foreach ($weatherForecast->getList() as $weather) {
110110
echo $weather->getDateTime()->format('Y-m-d H:i:s');
@@ -125,7 +125,7 @@ Get current air pollution data.
125125
Returns a [`AirPollutionLocation`](05-objects.md#airpollutionlocation) object:
126126

127127
```php
128-
$airPollution = $openWeatherMap->getAirPollution()->getCurrent(50, 50);
128+
$airPollution = $openWeatherMap->airPollution->getCurrent(50, 50);
129129

130130
echo $airPollution->getAirQuality()->getQualitativeName();
131131
echo $airPollution->getCarbonMonoxide();
@@ -142,7 +142,7 @@ Get air pollution forecast data per 1-hour for the next 24 hours.
142142
Returns a [`AirPollutionLocationList`](05-objects.md#airpollutionlocationlist) object:
143143

144144
```php
145-
$airPollutionForecast = $openWeatherMap->getAirPollution()->getForecast(50, 50);
145+
$airPollutionForecast = $openWeatherMap->airPollution->getForecast(50, 50);
146146

147147
foreach ($airPollutionForecast->getList() as $airPollution) {
148148
echo $airPollution->getDateTime()->format('Y-m-d H:i:s');
@@ -164,7 +164,7 @@ Returns a [`AirPollutionLocationList`](05-objects.md#airpollutionlocationlist) o
164164
```php
165165
$startDate = new \DateTime('-7 days'); // 7 days ago
166166
$endDate = new \DateTime('-6 days'); // 6 days ago
167-
$airPollutionHistory = $openWeatherMap->getAirPollution()->getHistory(50, 50, $startDate, $endDate);
167+
$airPollutionHistory = $openWeatherMap->airPollution->getHistory(50, 50, $startDate, $endDate);
168168

169169
foreach ($airPollutionHistory->getList() as $airPollution) {
170170
echo $airPollution->getDateTime()->format('Y-m-d H:i:s');
@@ -189,7 +189,7 @@ Get locations data by location name.
189189
Returns an array of [`Location`](05-objects.md#location) objects:
190190

191191
```php
192-
$locations = $openWeatherMap->getGeocoding()->getByLocationName('lisbon');
192+
$locations = $openWeatherMap->geocoding->getByLocationName('lisbon');
193193

194194
foreach ($locations as $location) {
195195
echo $location->getName();
@@ -208,7 +208,7 @@ Get location data by zip/post code.
208208
Returns a [`ZipCodeLocation`](05-objects.md#zipcodelocation) object:
209209

210210
```php
211-
$location = $openWeatherMap->getGeocoding()->getByZipCode('1000-001', 'pt');
211+
$location = $openWeatherMap->geocoding->getByZipCode('1000-001', 'pt');
212212

213213
echo $location->getName();
214214
```
@@ -227,7 +227,7 @@ Get locations data by coordinate.
227227
Returns an array of [`Location`](05-objects.md#location) objects:
228228

229229
```php
230-
$locations = $openWeatherMap->getGeocoding()->getByCoordinate(50, 50);
230+
$locations = $openWeatherMap->geocoding->getByCoordinate(50, 50);
231231

232232
foreach ($locations as $location) {
233233
echo $location->getName();
@@ -251,7 +251,7 @@ Only available for [`OneCall`](#one-call) and [`Weather`](#weather) APIs.
251251
use ProgrammatorDev\OpenWeatherMap\UnitSystem\UnitSystem;
252252

253253
// Uses 'imperial' unit system for this request alone
254-
$openWeatherMap->getWeather()
254+
$openWeatherMap->weather
255255
->withUnitSystem(UnitSystem::IMPERIAL)
256256
->getCurrent(50, 50);
257257
```
@@ -270,7 +270,7 @@ Only available for [`OneCall`](#one-call) and [`Weather`](#weather) APIs.
270270
use ProgrammatorDev\OpenWeatherMap\Language\Language
271271

272272
// Uses 'pt' language for this request alone
273-
$openWeatherMap->getWeather()
273+
$openWeatherMap->weather
274274
->withLanguage(Language::PORTUGUESE)
275275
->getCurrent(50, 50);
276276
```
@@ -296,7 +296,7 @@ Available for all APIs if `cache` is enabled in the [configuration](02-configura
296296
use ProgrammatorDev\OpenWeatherMap\Language\Language
297297

298298
// Cache will be saved for 1 hour for this request alone
299-
$openWeatherMap->getWeather()
299+
$openWeatherMap->weather
300300
->withCacheTtl(3600)
301301
->getCurrent(50, 50);
302302
```

docs/04-error-handling.md

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

1717
try {
18-
$location = $openWeatherMap->getGeocoding()->getByZipCode('1000-001', 'pt');
18+
$location = $openWeatherMap->geocoding->getByZipCode('1000-001', 'pt');
1919

20-
$weather = $openWeatherMap->getOneCall()->getWeather(
20+
$weather = $openWeatherMap->oneCall->getWeather(
2121
$location->getCoordinate()->getLatitude(),
2222
$location->getCoordinate()->getLongitude()
2323
);
@@ -57,9 +57,9 @@ To catch all API errors with a single exception, `ApiErrorException` is availabl
5757
use ProgrammatorDev\OpenWeatherMap\Exception\ApiErrorException;
5858

5959
try {
60-
$location = $openWeatherMap->getGeocoding()->getByZipCode('1000-001', 'pt');
60+
$location = $openWeatherMap->geocoding->getByZipCode('1000-001', 'pt');
6161

62-
$weather = $openWeatherMap->getOneCall()->getWeather(
62+
$weather = $openWeatherMap->oneCall->getWeather(
6363
$location->getCoordinate()->getLatitude(),
6464
$location->getCoordinate()->getLongitude()
6565
);
@@ -80,7 +80,7 @@ use ProgrammatorDev\YetAnotherPhpValidator\Exception\ValidationException;
8080

8181
try {
8282
// An invalid latitude value is given
83-
$weather = $openWeatherMap->getWeather()->getCurrent(999, 50);
83+
$weather = $openWeatherMap->weather->getCurrent(999, 50);
8484
}
8585
catch (ValidationException $exception) {
8686
// Should print:

0 commit comments

Comments
 (0)