]> git.mxchange.org Git - friendica-addons.git/blob - curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/AbstractCache.php
added composer.json and needed libs
[friendica-addons.git] / curweather / vendor / cmfcmf / openweathermap-php-api / Cmfcmf / OpenWeatherMap / AbstractCache.php
1 <?php
2 /**
3  * OpenWeatherMap-PHP-API — A 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
11  * OpenWeatherMap before using this class:
12  *
13  * @see http://www.OpenWeatherMap.org
14  * @see http://www.OpenWeatherMap.org/terms
15  * @see http://openweathermap.org/appid
16  */
17
18 namespace Cmfcmf\OpenWeatherMap;
19
20 /**
21  * Abstract cache class to be overwritten by custom cache implementations.
22  */
23 abstract class AbstractCache
24 {
25     /**
26      * @var int $seconds Cache time in seconds.
27      */
28     protected $seconds;
29
30     /**
31      * Checks whether a cached weather data is available.
32      *
33      * @param string $url The unique url of the cached content.
34      *
35      * @return bool False if no cached information is available, otherwise true.
36      *
37      * You need to check if a cached result is outdated here. Return false in that case.
38      */
39     abstract public function isCached($url);
40
41     /**
42      * Returns cached weather data.
43      *
44      * @param string $url The unique url of the cached content.
45      *
46      * @return string|bool The cached data if it exists, false otherwise.
47      */
48     abstract public function getCached($url);
49
50     /**
51      * Saves cached weather data.
52      *
53      * @param string $url     The unique url of the cached content.
54      * @param string $content The weather data to cache.
55      *
56      * @return bool True on success, false on failure.
57      */
58     abstract public function setCached($url, $content);
59
60     /**
61      * Set after how much seconds the cache shall expire.
62      *
63      * @param int $seconds
64      */
65     public function setSeconds($seconds)
66     {
67         $this->seconds = $seconds;
68     }
69 }