Skip to content

Commit d8cb6ff

Browse files
author
Alex Seriy
committed
Fixed StyleCI errors.
1 parent dccb90d commit d8cb6ff

File tree

2 files changed

+42
-46
lines changed

2 files changed

+42
-46
lines changed

Examples/CurrentWeather.php

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414
* @see http://www.OpenWeatherMap.org/terms
1515
* @see http://openweathermap.org/appid
1616
*/
17-
1817
use Cmfcmf\OpenWeatherMap;
1918
use Cmfcmf\OpenWeatherMap\Exception as OWMException;
2019

2120
if (file_exists('../vendor/autoload.php')) {
2221
// Library is not part of a project. "composer install" was executed directly on this library's composer file.
23-
require('../vendor/autoload.php');
22+
require '../vendor/autoload.php';
2423
} else {
2524
// Library is part of a project.
2625
/** @noinspection PhpIncludeInspection */
27-
require('../../../autoload.php');
26+
require '../../../autoload.php';
2827
}
2928

3029
// Load the app configuration
@@ -63,123 +62,123 @@
6362
echo $weather->temperature->getUnit();
6463
echo "<br />\n";
6564

66-
/**
65+
/*
6766
* In the example above we're using a "shortcut". OpenWeatherMap returns the minimum temperature of a day,
6867
* the maximum temperature and the temperature right now. If you don't specify which temperature you want, it will default
6968
* to the current temperature. See below how to access the other values. Notice that each of them has implemented the methods
7069
* "getFormatted()", "getValue()", "getUnit()".
7170
*/
7271

7372
// Returns the current temperature:
74-
echo "Current: " . $weather->temperature->now;
73+
echo 'Current: '.$weather->temperature->now;
7574
echo "<br />\n";
7675

7776
// Returns the minimum temperature:
78-
echo "Minimum: " . $weather->temperature->min;
77+
echo 'Minimum: '.$weather->temperature->min;
7978
echo "<br />\n";
8079

8180
// Returns the maximum temperature:
82-
echo "Maximum: " . $weather->temperature->max;
81+
echo 'Maximum: '.$weather->temperature->max;
8382
echo "<br />\n";
8483

85-
/**
84+
/*
8685
* When speaking about "current" and "now", this means when the weather data was last updated. You can get this
8786
* via a DateTime object:
8887
*/
89-
echo "Last update: " . $weather->lastUpdate->format('r');
88+
echo 'Last update: '.$weather->lastUpdate->format('r');
9089
echo "<br />\n";
9190

9291
// Example 2: Get current pressure and humidity in Hongkong.
9392
$weather = $owm->getWeather('Hongkong', $units, $lang);
9493
echo "<br /><br />\n\n\nEXAMPLE 2<hr />\n\n\n";
9594

96-
/**
95+
/*
9796
* You can use the methods above to only get the value or the unit.
9897
*/
9998

100-
echo "Pressure: " . $weather->pressure;
99+
echo 'Pressure: '.$weather->pressure;
101100
echo "<br />\n";
102-
echo "Humidity: " . $weather->humidity;
101+
echo 'Humidity: '.$weather->humidity;
103102
echo "<br />\n";
104103

105104
// Example 3: Get today's sunrise and sunset times.
106105
echo "<br /><br />\n\n\nEXAMPLE 3<hr />\n\n\n";
107106

108-
/**
107+
/*
109108
* These functions return a DateTime object.
110109
*/
111110

112-
echo "Sunrise: " . $weather->sun->rise->format('r');
111+
echo 'Sunrise: '.$weather->sun->rise->format('r');
113112
echo "<br />\n";
114-
echo "Sunset: " . $weather->sun->set->format('r');
113+
echo 'Sunset: '.$weather->sun->set->format('r');
115114
echo "<br />\n";
116115

117116
// Example 4: Get current temperature from coordinates (Greenland :-) ).
118117
$weather = $owm->getWeather(array('lat' => 77.73038, 'lon' => 41.89604), $units, $lang);
119118
echo "<br /><br />\n\n\nEXAMPLE 4<hr />\n\n\n";
120119

121-
echo "Temperature: " . $weather->temperature;
120+
echo 'Temperature: '.$weather->temperature;
122121
echo "<br />\n";
123122

124123
// Example 5: Get current temperature from city id. The city is an internal id used by OpenWeatherMap. See example 6 too.
125124
$weather = $owm->getWeather(2172797, $units, $lang);
126125
echo "<br /><br />\n\n\nEXAMPLE 5<hr />\n\n\n";
127126

128-
echo "City: " . $weather->city->name;
127+
echo 'City: '.$weather->city->name;
129128
echo "<br />\n";
130129

131-
echo "Temperature: " . $weather->temperature;
130+
echo 'Temperature: '.$weather->temperature;
132131
echo "<br />\n";
133132

134133
// Example 6: Get information about a city.
135134
$weather = $owm->getWeather('Paris', $units, $lang);
136135
echo "<br /><br />\n\n\nEXAMPLE 6<hr />\n\n\n";
137136

138-
echo "Id: " . $weather->city->id;
137+
echo 'Id: '.$weather->city->id;
139138
echo "<br />\n";
140139

141-
echo "Name: " . $weather->city->name;
140+
echo 'Name: '.$weather->city->name;
142141
echo "<br />\n";
143142

144-
echo "Lon: " . $weather->city->lon;
143+
echo 'Lon: '.$weather->city->lon;
145144
echo "<br />\n";
146145

147-
echo "Lat: " . $weather->city->lat;
146+
echo 'Lat: '.$weather->city->lat;
148147
echo "<br />\n";
149148

150-
echo "Country: " . $weather->city->country;
149+
echo 'Country: '.$weather->city->country;
151150
echo "<br />\n";
152151

153152
// Example 7: Get wind information.
154153
echo "<br /><br />\n\n\nEXAMPLE 7<hr />\n\n\n";
155154

156-
echo "Speed: " . $weather->wind->speed;
155+
echo 'Speed: '.$weather->wind->speed;
157156
echo "<br />\n";
158157

159-
echo "Direction: " . $weather->wind->direction;
158+
echo 'Direction: '.$weather->wind->direction;
160159
echo "<br />\n";
161160

162-
/**
161+
/*
163162
* For speed and direction there is a description available, which isn't always translated.
164163
*/
165164

166-
echo "Speed: " . $weather->wind->speed->getDescription();
165+
echo 'Speed: '.$weather->wind->speed->getDescription();
167166
echo "<br />\n";
168167

169-
echo "Direction: " . $weather->wind->direction->getDescription();
168+
echo 'Direction: '.$weather->wind->direction->getDescription();
170169
echo "<br />\n";
171170

172171
// Example 8: Get information about the clouds.
173172
echo "<br /><br />\n\n\nEXAMPLE 8<hr />\n\n\n";
174173

175174
// The number in braces seems to be an indicator how cloudy the sky is.
176-
echo "Clouds: " . $weather->clouds->getDescription() . " (" . $weather->clouds . ")";
175+
echo 'Clouds: '.$weather->clouds->getDescription().' ('.$weather->clouds.')';
177176
echo "<br />\n";
178177

179178
// Example 9: Get information about precipitation.
180179
echo "<br /><br />\n\n\nEXAMPLE 9<hr />\n\n\n";
181180

182-
echo "Precipation: " . $weather->precipitation->getDescription() . " (" . $weather->precipitation . ")";
181+
echo 'Precipation: '.$weather->precipitation->getDescription().' ('.$weather->precipitation.')';
183182
echo "<br />\n";
184183

185184
// Example 10: Show copyright notice. WARNING: This is no offical text. This hint was created regarding to http://www.http://openweathermap.org/copyright .
@@ -191,13 +190,13 @@
191190
// Example 11: Get raw xml data.
192191
echo "<br /><br />\n\n\nEXAMPLE 11<hr />\n\n\n";
193192

194-
echo "<pre><code>" . htmlspecialchars($owm->getRawWeatherData('Berlin', $units, $lang, null, 'xml')) . "</code></pre>";
193+
echo '<pre><code>'.htmlspecialchars($owm->getRawWeatherData('Berlin', $units, $lang, null, 'xml')).'</code></pre>';
195194
echo "<br />\n";
196195

197196
// Example 12: Get raw json data.
198197
echo "<br /><br />\n\n\nEXAMPLE 12<hr />\n\n\n";
199198

200-
echo "<code>" . htmlspecialchars($owm->getRawWeatherData('Berlin', $units, $lang, null, 'json')) . "</code>";
199+
echo '<code>'.htmlspecialchars($owm->getRawWeatherData('Berlin', $units, $lang, null, 'json')).'</code>';
201200
echo "<br />\n";
202201

203202
// Example 13: Get raw html data.
@@ -211,34 +210,33 @@
211210

212211
// Try wrong city name.
213212
try {
214-
$weather = $owm->getWeather("ThisCityNameIsNotValidAndDoesNotExist", $units, $lang);
213+
$weather = $owm->getWeather('ThisCityNameIsNotValidAndDoesNotExist', $units, $lang);
215214
} catch (OWMException $e) {
216-
echo $e->getMessage() . ' (Code ' . $e->getCode() . ').';
215+
echo $e->getMessage().' (Code '.$e->getCode().').';
217216
echo "<br />\n";
218217
}
219218

220219
// Try invalid $query.
221220
try {
222221
$weather = $owm->getWeather(new \DateTime('now'), $units, $lang);
223222
} catch (\Exception $e) {
224-
echo $e->getMessage() . ' (Code ' . $e->getCode() . ').';
223+
echo $e->getMessage().' (Code '.$e->getCode().').';
225224
echo "<br />\n";
226225
}
227226

228227
// Full error handling would look like this:
229228
try {
230229
$weather = $owm->getWeather(-1, $units, $lang);
231230
} catch (OWMException $e) {
232-
echo 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').';
231+
echo 'OpenWeatherMap exception: '.$e->getMessage().' (Code '.$e->getCode().').';
233232
echo "<br />\n";
234233
} catch (\Exception $e) {
235-
echo 'General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').';
234+
echo 'General exception: '.$e->getMessage().' (Code '.$e->getCode().').';
236235
echo "<br />\n";
237236
}
238237

239238
// Example 15: Using an api key:
240239
echo "<br /><br />\n\n\nEXAMPLE 15<hr />\n\n\n";
241240
$weather = $owm->getWeather('Berlin', $units, $lang, $myApiKey);
242-
echo $weather->temperature . "\n";
243-
echo "<br />\n";
244-
241+
echo $weather->temperature."\n";
242+
echo "<br />\n";

Examples/WeatherHistory.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
* @see http://www.OpenWeatherMap.org/terms
1515
* @see http://openweathermap.org/appid
1616
*/
17-
1817
use Cmfcmf\OpenWeatherMap;
1918

2019
if (file_exists('../vendor/autoload.php')) {
2120
// Library is not part of a project. "composer install" was executed directly on this library's composer file.
22-
require('../vendor/autoload.php');
21+
require '../vendor/autoload.php';
2322
} else {
2423
// Library is part of a project.
2524
/** @noinspection PhpIncludeInspection */
26-
require('../../../autoload.php');
25+
require '../../../autoload.php';
2726
}
2827

2928
// Load the app configuration
@@ -43,6 +42,5 @@
4342
$history = $owm->getWeatherHistory('Berlin', new \DateTime('2014-01-01'), new \DateTime('now'), 'hour', $units, $lang);
4443

4544
foreach ($history as $weather) {
46-
echo "Average temperature at " . $weather->time->format('d.m.Y H:i') . ": " . $weather->temperature . "\n\r<br />";
47-
}
48-
45+
echo 'Average temperature at '.$weather->time->format('d.m.Y H:i').': '.$weather->temperature."\n\r<br />";
46+
}

0 commit comments

Comments
 (0)