2
2
3
3
- [ APIs] ( #apis )
4
4
- [ One Call] ( #one-call )
5
- - [ getWeather] ( #getweatherfloat-latitude-float-longitude )
6
- - [ getHistoryMoment] ( #gethistorymomentfloat-latitude-float-longitude-datetimeinterface-datetime )
7
- - [ getHistoryAggregate] ( #gethistoryaggregatefloat-latitude-float-longitude-datetimeinterface-date )
5
+ - [ getWeather] ( #getweather )
6
+ - [ getHistoryMoment] ( #gethistorymoment )
7
+ - [ getHistoryAggregate] ( #gethistoryaggregate )
8
8
- [ Weather] ( #weather )
9
- - [ getCurrent] ( #getcurrentfloat-latitude-float-longitude )
10
- - [ getForecast] ( #getforecastfloat-latitude-float-longitude-int-numresults--40 )
9
+ - [ getCurrent] ( #getcurrent )
10
+ - [ getForecast] ( #getforecast )
11
11
- [ Air Pollution] ( #air-pollution )
12
- - [ getCurrent] ( #getcurrentfloat-latitude-float-longitude -1 )
13
- - [ getForecast] ( #getforecastfloat-latitude-float-longitude )
14
- - [ getHistory] ( #gethistoryfloat-latitude-float-longitude-datetimeinterface-startdate-datetimeinterface-enddate )
12
+ - [ getCurrent] ( #getcurrent -1 )
13
+ - [ getForecast] ( #getforecast-1 )
14
+ - [ getHistory] ( #gethistory )
15
15
- [ Geocoding] ( #geocoding )
16
- - [ getByLocationName] ( #getbylocationnamestring-locationname-int-numresults--5 )
17
- - [ getByZipCode] ( #getbyzipcodestring-zipcode-string-countrycode )
18
- - [ getByCoordinate] ( #getbycoordinatefloat-latitude-float-longitude-int-numresults--5 )
16
+ - [ getByLocationName] ( #getbylocationname )
17
+ - [ getByZipCode] ( #getbyzipcode )
18
+ - [ getByCoordinate] ( #getbycoordinate )
19
19
- [ Common Methods] ( #common-methods )
20
- - [ withUnitSystem] ( #withunitsystemstring-unitsystem )
21
- - [ withLanguage] ( #withlanguagestring-language )
22
- - [ withCacheTtl] ( #withcachettlint-time )
20
+ - [ withUnitSystem] ( #withunitsystem )
21
+ - [ withLanguage] ( #withlanguage )
22
+ - [ withCacheTtl] ( #withcachettl )
23
23
24
24
## APIs
25
25
26
26
### One Call
27
27
28
- #### ` getWeather(float $latitude, float $longitude) `
28
+ #### ` getWeather `
29
+
30
+ ``` php
31
+ getWeather(float $latitude, float $longitude): OneCall
32
+ ```
29
33
30
34
Get current and forecast (minutely, hourly and daily) weather data.
31
35
32
- Returns a [ ` OneCall ` ] ( 05-objects.md#onecall ) object.
36
+ Returns a [ ` OneCall ` ] ( 05-objects.md#onecall ) object:
33
37
34
38
``` php
35
39
$weather = $openWeatherMap->getOneCall()->getWeather(50, 50);
36
40
37
41
echo $weather->getCurrent()->getTemperature();
38
42
```
39
43
40
- #### ` getHistoryMoment(float $latitude, float $longitude, \DateTimeInterface $dateTime) `
44
+ #### ` getHistoryMoment `
45
+
46
+ ``` php
47
+ getHistoryMoment(float $latitude, float $longitude, \DateTimeInterface $dateTime): WeatherLocation
48
+ ```
41
49
42
50
Get weather data from a single moment in the past.
43
51
44
- Returns a [ ` WeatherLocation ` ] ( 05-objects.md#weatherlocation ) object.
52
+ Returns a [ ` WeatherLocation ` ] ( 05-objects.md#weatherlocation ) object:
45
53
46
54
``` php
47
55
$weather = $openWeatherMap->getOneCall()->getHistoryMoment(50, 50, new \DateTime('2023-01-01 12:00:00'));
48
56
49
57
echo $weather->getTemperature();
50
58
```
51
59
52
- #### ` getHistoryAggregate(float $latitude, float $longitude, \DateTimeInterface $date) `
60
+ #### ` getHistoryAggregate `
61
+
62
+ ``` php
63
+ getHistoryAggregate(float $latitude, float $longitude, \DateTimeInterface $date): WeatherAggregate
64
+ ```
53
65
54
66
Get aggregated weather data from a single day in the past.
55
67
56
- Returns a [ ` WeatherAggregate ` ] ( 05-objects.md#weatheraggregate ) object.
68
+ Returns a [ ` WeatherAggregate ` ] ( 05-objects.md#weatheraggregate ) object:
57
69
58
70
``` php
59
71
$weather = $openWeatherMap->getOneCall()->getHistoryAggregate(50, 50, new \DateTime('1985-07-19'));
@@ -63,23 +75,31 @@ echo $weather->getTemperature();
63
75
64
76
### Weather
65
77
66
- #### ` getCurrent(float $latitude, float $longitude) `
78
+ #### ` getCurrent `
79
+
80
+ ``` php
81
+ getCurrent(float $latitude, float $longitude): WeatherLocation
82
+ ```
67
83
68
84
Get current weather data.
69
85
70
- Returns a [ ` WeatherLocation ` ] ( 05-objects.md#weatherlocation-1 ) object.
86
+ Returns a [ ` WeatherLocation ` ] ( 05-objects.md#weatherlocation-1 ) object:
71
87
72
88
``` php
73
89
$weather = $openWeatherMap->getWeather()->getCurrent(50, 50);
74
90
75
91
echo $weather->getTemperature();
76
92
```
77
93
78
- #### ` getForecast(float $latitude, float $longitude, int $numResults = 40) `
94
+ #### ` getForecast `
95
+
96
+ ``` php
97
+ getForecast(float $latitude, float $longitude, int $numResults = 40): WeatherLocationList
98
+ ```
79
99
80
100
Get weather forecast data per 3-hour steps for the next 5 days.
81
101
82
- Returns a [ ` WeatherLocationList ` ] ( 05-objects.md#weatherlocationlist ) object.
102
+ Returns a [ ` WeatherLocationList ` ] ( 05-objects.md#weatherlocationlist ) object:
83
103
84
104
``` php
85
105
// Since it returns 3-hour steps,
@@ -94,11 +114,15 @@ foreach ($weatherForecast->getList() as $weather) {
94
114
95
115
### Air Pollution
96
116
97
- #### ` getCurrent(float $latitude, float $longitude) `
117
+ #### ` getCurrent `
118
+
119
+ ``` php
120
+ getCurrent(float $latitude, float $longitude): AirPollutionLocation
121
+ ```
98
122
99
123
Get current air pollution data.
100
124
101
- Returns a [ ` AirPollutionLocation ` ] ( 05-objects.md#airpollutionlocation ) object.
125
+ Returns a [ ` AirPollutionLocation ` ] ( 05-objects.md#airpollutionlocation ) object:
102
126
103
127
``` php
104
128
$airPollution = $openWeatherMap->getAirPollution()->getCurrent(50, 50);
@@ -107,11 +131,15 @@ echo $airPollution->getAirQuality()->getQualitativeName();
107
131
echo $airPollution->getCarbonMonoxide();
108
132
```
109
133
110
- #### ` getForecast(float $latitude, float $longitude) `
134
+ #### ` getForecast `
135
+
136
+ ``` php
137
+ getForecast(float $latitude, float $longitude): AirPollutionLocationList
138
+ ```
111
139
112
140
Get air pollution forecast data per 1-hour for the next 24 hours.
113
141
114
- Returns a [ ` AirPollutionLocationList ` ] ( 05-objects.md#airpollutionlocationlist ) object.
142
+ Returns a [ ` AirPollutionLocationList ` ] ( 05-objects.md#airpollutionlocationlist ) object:
115
143
116
144
``` php
117
145
$airPollutionForecast = $openWeatherMap->getAirPollution()->getForecast(50, 50);
@@ -123,11 +151,15 @@ foreach ($airPollutionForecast->getList() as $airPollution) {
123
151
}
124
152
```
125
153
126
- #### ` getHistory(float $latitude, float $longitude, \DateTimeInterface $startDate, \DateTimeInterface $endDate) `
154
+ #### ` getHistory `
155
+
156
+ ``` php
157
+ getHistory(float $latitude, float $longitude, \DateTimeInterface $startDate, \DateTimeInterface $endDate): AirPollutionLocationList
158
+ ```
127
159
128
160
Get air pollution history data between two dates.
129
161
130
- Returns a [ ` AirPollutionLocationList ` ] ( 05-objects.md#airpollutionlocationlist ) object.
162
+ Returns a [ ` AirPollutionLocationList ` ] ( 05-objects.md#airpollutionlocationlist ) object:
131
163
132
164
``` php
133
165
$startDate = new \DateTime('-7 days'); // 7 days ago
@@ -143,11 +175,18 @@ foreach ($airPollutionHistory->getList() as $airPollution) {
143
175
144
176
### Geocoding
145
177
146
- #### ` getByLocationName(string $locationName, int $numResults = 5) `
178
+ #### ` getByLocationName `
179
+
180
+ ``` php
181
+ /**
182
+ * @return Location[]
183
+ */
184
+ getByLocationName(string $locationName, int $numResults = 5): array
185
+ ```
147
186
148
187
Get locations data by location name.
149
188
150
- Returns an array of [ ` Location ` ] ( 05-objects.md#location ) objects.
189
+ Returns an array of [ ` Location ` ] ( 05-objects.md#location ) objects:
151
190
152
191
``` php
153
192
$locations = $openWeatherMap->getGeocoding()->getByLocationName('lisbon');
@@ -158,23 +197,34 @@ foreach ($locations as $location) {
158
197
}
159
198
```
160
199
161
- #### ` getByZipCode(string $zipCode, string $countryCode) `
200
+ #### ` getByZipCode `
201
+
202
+ ``` php
203
+ getByZipCode(string $zipCode, string $countryCode): ZipCodeLocation
204
+ ```
162
205
163
206
Get location data by zip/post code.
164
207
165
- Returns a [ ` ZipCodeLocation ` ] ( 05-objects.md#zipcodelocation ) object.
208
+ Returns a [ ` ZipCodeLocation ` ] ( 05-objects.md#zipcodelocation ) object:
166
209
167
210
``` php
168
211
$location = $openWeatherMap->getGeocoding()->getByZipCode('1000-001', 'pt');
169
212
170
213
echo $location->getName();
171
214
```
172
215
173
- #### ` getByCoordinate(float $latitude, float $longitude, int $numResults = 5) `
216
+ #### ` getByCoordinate `
217
+
218
+ ``` php
219
+ /**
220
+ * @return Location[]
221
+ */
222
+ getByCoordinate(float $latitude, float $longitude, int $numResults = 5): array
223
+ ```
174
224
175
225
Get locations data by coordinate.
176
226
177
- Returns an array of [ ` Location ` ] ( 05-objects.md#location ) objects.
227
+ Returns an array of [ ` Location ` ] ( 05-objects.md#location ) objects:
178
228
179
229
``` php
180
230
$locations = $openWeatherMap->getGeocoding()->getByCoordinate(50, 50);
@@ -187,7 +237,11 @@ foreach ($locations as $location) {
187
237
188
238
## Common Methods
189
239
190
- #### ` withUnitSystem(string $unitSystem) `
240
+ #### ` withUnitSystem `
241
+
242
+ ``` php
243
+ withUnitSystem(string $unitSystem): self
244
+ ```
191
245
192
246
Makes a request with a different unit system from the one globally defined in the [ configuration] ( 02-configuration.md#unitsystem ) .
193
247
@@ -202,7 +256,11 @@ $openWeatherMap->getWeather()
202
256
->getCurrent(50, 50);
203
257
```
204
258
205
- #### ` withLanguage(string $language) `
259
+ #### ` withLanguage `
260
+
261
+ ``` php
262
+ withLanguage(string $language): self
263
+ ```
206
264
207
265
Makes a request with a different language from the one globally defined in the [ configuration] ( 02-configuration.md#language ) .
208
266
@@ -217,7 +275,11 @@ $openWeatherMap->getWeather()
217
275
->getCurrent(50, 50);
218
276
```
219
277
220
- #### ` withCacheTtl(?int $time) `
278
+ #### ` withCacheTtl `
279
+
280
+ ``` php
281
+ withCacheTtl(?int $time): self
282
+ ```
221
283
222
284
Makes a request and saves into cache with the provided time duration value (in seconds).
223
285
Check the [ Cache TTL] ( 02-configuration.md#cache-ttl ) section for more information regarding default values.
0 commit comments