|
1 | 1 | <?php |
| 2 | +/** |
| 3 | + * OpenWeatherMap-PHP-API — An php api to parse weather data from http://www.OpenWeatherMap.org . |
| 4 | + * |
| 5 | + * @license MIT |
| 6 | + * |
| 7 | + * Please see the LICENSE file distributed with this source code for further |
| 8 | + * information regarding copyright and licensing. |
| 9 | + * |
| 10 | + * Please visit the following links to read about the usage policies and the license of OpenWeatherMap before using this class. |
| 11 | + * @see http://www.OpenWeatherMap.org |
| 12 | + * @see http://www.OpenWeatherMap.org/about |
| 13 | + * @see http://www.OpenWeatherMap.org/copyright |
| 14 | + * @see http://openweathermap.org/appid |
| 15 | + */ |
2 | 16 |
|
3 | 17 | use cmfcmf\OpenWeatherMap; |
| 18 | +use cmfcmf\OpenWeatherMap\AbstractCache; |
4 | 19 |
|
5 | 20 | require('cmfcmf/OpenWeatherMap.php'); |
6 | 21 |
|
| 22 | +/** |
| 23 | + * Example cache implementation. |
| 24 | + * |
| 25 | + * @ignore |
| 26 | + */ |
| 27 | +class ExampleCache extends AbstractCache |
| 28 | +{ |
| 29 | + /** |
| 30 | + * @inheritdoc |
| 31 | + */ |
| 32 | + public function isCached($type, $query, $units, $lang, $mode) |
| 33 | + { |
| 34 | + echo "Checking cache for $type $query $units $lang $mode …<br />"; |
| 35 | + return false; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @inheritdoc |
| 40 | + */ |
| 41 | + public function getCached($type, $query, $units, $lang, $mode) |
| 42 | + { |
| 43 | + echo "Get cache for $type $query $units $lang $mode …<br />"; |
| 44 | + return false; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @inheritdoc |
| 49 | + */ |
| 50 | + public function setCached($type, $content, $query, $units, $lang, $mode) |
| 51 | + { |
| 52 | + echo "Set cache for $type $query $units $lang $mode … ({$this->seconds} seconds)<br />"; |
| 53 | + return false; |
| 54 | + } |
| 55 | +} |
| 56 | + |
7 | 57 | // Language of data (try your own language here!): |
8 | 58 | $lang = 'de'; |
9 | 59 |
|
10 | 60 | // Units (can be 'metric' or 'imperial' [default]): |
11 | 61 | $units = 'metric'; |
12 | 62 |
|
13 | 63 | // Example 1: Use your own cache implementation. See the example_cache file. |
14 | | -$owm = new OpenWeatherMap('examplecache', 100); |
| 64 | +$owm = new OpenWeatherMap('ExampleCache', 100); |
15 | 65 |
|
16 | 66 | $weather = $owm->getWeather('Berlin', $units, $lang); |
17 | 67 | echo "EXAMPLE 1<hr />\n\n\n"; |
|
0 commit comments