From 1f74d409a2ff1dc64afb5ff075684356275fc3aa Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sat, 11 Jul 2015 20:21:09 +0200 Subject: [PATCH] added composer.json and needed libs --- curweather/composer.json | 5 + curweather/vendor/autoload.php | 7 + .../cmfcmf/openweathermap-php-api/.gitignore | 1 + .../cmfcmf/openweathermap-php-api/.travis.yml | 22 + .../Cmfcmf/OpenWeatherMap.php | 598 +++++++++++ .../Cmfcmf/OpenWeatherMap/AbstractCache.php | 69 ++ .../Cmfcmf/OpenWeatherMap/CurrentWeather.php | 117 +++ .../Cmfcmf/OpenWeatherMap/Exception.php | 27 + .../OpenWeatherMap/Fetcher/CurlFetcher.php | 42 + .../Fetcher/FetcherInterface.php | 37 + .../Fetcher/FileGetContentsFetcher.php | 34 + .../Cmfcmf/OpenWeatherMap/Forecast.php | 83 ++ .../Cmfcmf/OpenWeatherMap/History.php | 104 ++ .../Cmfcmf/OpenWeatherMap/Util/City.php | 76 ++ .../Cmfcmf/OpenWeatherMap/Util/Sun.php | 52 + .../OpenWeatherMap/Util/Temperature.php | 105 ++ .../Cmfcmf/OpenWeatherMap/Util/Time.php | 65 ++ .../Cmfcmf/OpenWeatherMap/Util/Unit.php | 128 +++ .../Cmfcmf/OpenWeatherMap/Util/Weather.php | 82 ++ .../Cmfcmf/OpenWeatherMap/Util/Wind.php | 48 + .../Cmfcmf/OpenWeatherMap/WeatherForecast.php | 136 +++ .../Cmfcmf/OpenWeatherMap/WeatherHistory.php | 118 +++ .../openweathermap-php-api/Examples/Cache.php | 95 ++ .../Examples/CurrentWeather.php | 236 +++++ .../Examples/WeatherForecast.php | 69 ++ .../Examples/WeatherHistory.php | 43 + .../cmfcmf/openweathermap-php-api/LICENSE | 19 + .../cmfcmf/openweathermap-php-api/README.md | 83 ++ .../openweathermap-php-api/composer.json | 30 + .../openweathermap-php-api/composer.lock | 973 ++++++++++++++++++ .../openweathermap-php-api/phpunit.xml.dist | 22 + .../tests/Fetcher/CurlFetcherTest.php | 53 + .../Fetcher/FileGetContentsFetcherTest.php | 59 ++ .../tests/Util/SunTest.php | 62 ++ .../tests/Util/UnitTest.php | 159 +++ .../tests/bootstrap.php | 12 + curweather/vendor/composer/ClassLoader.php | 413 ++++++++ .../vendor/composer/autoload_classmap.php | 9 + .../vendor/composer/autoload_namespaces.php | 10 + curweather/vendor/composer/autoload_psr4.php | 9 + curweather/vendor/composer/autoload_real.php | 50 + curweather/vendor/composer/installed.json | 51 + 42 files changed, 4413 insertions(+) create mode 100644 curweather/composer.json create mode 100644 curweather/vendor/autoload.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/.gitignore create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/.travis.yml create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/AbstractCache.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/CurrentWeather.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Exception.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Fetcher/CurlFetcher.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Fetcher/FetcherInterface.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Fetcher/FileGetContentsFetcher.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Forecast.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/History.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/City.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Sun.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Temperature.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Time.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Unit.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Weather.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Wind.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherForecast.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherHistory.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Examples/Cache.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Examples/CurrentWeather.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherForecast.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherHistory.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/LICENSE create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/README.md create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/composer.json create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/composer.lock create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/phpunit.xml.dist create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/CurlFetcherTest.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/FileGetContentsFetcherTest.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/SunTest.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/UnitTest.php create mode 100644 curweather/vendor/cmfcmf/openweathermap-php-api/tests/bootstrap.php create mode 100644 curweather/vendor/composer/ClassLoader.php create mode 100644 curweather/vendor/composer/autoload_classmap.php create mode 100644 curweather/vendor/composer/autoload_namespaces.php create mode 100644 curweather/vendor/composer/autoload_psr4.php create mode 100644 curweather/vendor/composer/autoload_real.php create mode 100644 curweather/vendor/composer/installed.json diff --git a/curweather/composer.json b/curweather/composer.json new file mode 100644 index 00000000..d54ac721 --- /dev/null +++ b/curweather/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "cmfcmf/openweathermap-php-api": "~2.0" + } +} diff --git a/curweather/vendor/autoload.php b/curweather/vendor/autoload.php new file mode 100644 index 00000000..9e1325a6 --- /dev/null +++ b/curweather/vendor/autoload.php @@ -0,0 +1,7 @@ +OpenWeatherMap.org"; + + /** + * @var \Cmfcmf\OpenWeatherMap\AbstractCache|bool $cacheClass The cache class. + */ + private $cacheClass = false; + + /** + * @var int + */ + private $seconds; + + /** + * @var FetcherInterface The url fetcher. + */ + private $fetcher; + + /** + * Constructs the OpenWeatherMap object. + * + * @param null|FetcherInterface $fetcher The interface to fetch the data from OpenWeatherMap. Defaults to + * CurlFetcher() if cURL is available. Otherwise defaults to + * FileGetContentsFetcher() using 'file_get_contents()'. + * @param bool|string $cacheClass If set to false, caching is disabled. Otherwise this must be a class + * extending AbstractCache. Defaults to false. + * @param int $seconds How long weather data shall be cached. Default 10 minutes. + * + * @throws \Exception If $cache is neither false nor a valid callable extending Cmfcmf\OpenWeatherMap\Util\Cache. + * @api + */ + public function __construct($fetcher = null, $cacheClass = false, $seconds = 600) + { + if ($cacheClass !== false && !($cacheClass instanceof AbstractCache)) { + throw new \Exception("The cache class must implement the FetcherInterface!"); + } + if (!is_numeric($seconds)) { + throw new \Exception("\$seconds must be numeric."); + } + if (!isset($fetcher)) { + $fetcher = (function_exists('curl_version')) ? new CurlFetcher() : new FileGetContentsFetcher(); + } + if ($seconds == 0) { + $cacheClass = false; + } + + $this->cacheClass = $cacheClass; + $this->seconds = $seconds; + $this->fetcher = $fetcher; + } + + /** + * Returns the current weather at the place you specified as an object. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * + * @throws OpenWeatherMap\Exception If OpenWeatherMap returns an error. + * @throws \InvalidArgumentException If an argument error occurs. + * + * @return CurrentWeather The weather object. + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getWeather($query, $units = 'imperial', $lang = 'en', $appid = '') + { + // Disable default error handling of SimpleXML (Do not throw E_WARNINGs). + libxml_use_internal_errors(true); + libxml_clear_errors(); + + $answer = $this->getRawWeatherData($query, $units, $lang, $appid, 'xml'); + + try { + $xml = new \SimpleXMLElement($answer); + } catch (\Exception $e) { + // Invalid xml format. This happens in case OpenWeatherMap returns an error. + // OpenWeatherMap always uses json for errors, even if one specifies xml as format. + $error = json_decode($answer, true); + if (isset($error['message'])) { + throw new OWMException($error['message'], $error['cod']); + } else { + throw new OWMException('Unknown fatal error: OpenWeatherMap returned the following json object: ' . $answer); + } + } + + return new CurrentWeather($xml, $units); + } + + /** + * Returns the current weather at the place you specified as an object. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * @param int $days For how much days you want to get a forecast. Default 1, maximum: 16. + * + * @throws OpenWeatherMap\Exception If OpenWeatherMap returns an error. + * @throws \InvalidArgumentException If an argument error occurs. + * + * @return WeatherForecast The WeatherForecast object. + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getWeatherForecast($query, $units = 'imperial', $lang = 'en', $appid = '', $days = 1) + { + // Disable default error handling of SimpleXML (Do not throw E_WARNINGs). + libxml_use_internal_errors(true); + libxml_clear_errors(); + + if ($days <= 5) { + $answer = $this->getRawHourlyForecastData($query, $units, $lang, $appid, 'xml'); + } else if ($days <= 16) { + $answer = $this->getRawDailyForecastData($query, $units, $lang, $appid, 'xml', $days); + } else { + throw new \InvalidArgumentException('Error: forecasts are only available for the next 16 days. $days must be lower than 17.'); + } + + try { + $xml = new \SimpleXMLElement($answer); + } catch (\Exception $e) { + // Invalid xml format. This happens in case OpenWeatherMap returns an error. + // OpenWeatherMap always uses json for errors, even if one specifies xml as format. + $error = json_decode($answer, true); + if (isset($error['message'])) { + throw new OWMException($error['message'], $error['cod']); + } else { + throw new OWMException('Unknown fatal error: OpenWeatherMap returned the following json object: ' . $answer); + } + } + + return new WeatherForecast($xml, $units, $days); + } + + /** + * Returns the weather history for the place you specified as an object. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param \DateTime $start + * @param int $endOrCount + * @param string $type + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * + * @throws OpenWeatherMap\Exception If OpenWeatherMap returns an error. + * @throws \InvalidArgumentException If an argument error occurs. + * + * @return WeatherHistory The WeatherHistory object. + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getWeatherHistory($query, \DateTime $start, $endOrCount = 1, $type = 'hour', $units = 'imperial', $lang = 'en', $appid = '') + { + if (!in_array($type, array('tick', 'hour', 'day'))) { + throw new \InvalidArgumentException('$type must be either "tick", "hour" or "day"'); + } + + $xml = json_decode($this->getRawWeatherHistory($query, $start, $endOrCount, $type, $units, $lang, $appid), true); + + if ($xml['cod'] != 200) { + throw new OWMException($xml['message'], $xml['cod']); + } + + return new WeatherHistory($xml, $query); + } + + /** + * @deprecated Use {@link self::getRawWeatherData()} instead. + */ + public function getRawData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml') + { + return $this->getRawWeatherData($query, $units, $lang, $appid, $mode); + } + + /** + * Directly returns the xml/json/html string returned by OpenWeatherMap for the current weather. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default). + * + * @return string Returns false on failure and the fetched data in the format you specified on success. + * + * Warning If an error occurred, OpenWeatherMap returns data in json format ALWAYS + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getRawWeatherData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml') + { + $url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherUrl); + + return $this->cacheOrFetchResult($url); + } + + /** + * Directly returns the xml/json/html string returned by OpenWeatherMap for the hourly forecast. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default). + * + * @return string Returns false on failure and the fetched data in the format you specified on success. + * + * Warning If an error occurred, OpenWeatherMap returns data in json format ALWAYS + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getRawHourlyForecastData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml') + { + $url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherHourlyForecastUrl); + + return $this->cacheOrFetchResult($url); + } + + /** + * Directly returns the xml/json/html string returned by OpenWeatherMap for the daily forecast. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default) + * @param int $cnt How many days of forecast shall be returned? Maximum (and default): 16 + * + * @throws \InvalidArgumentException If $cnt is higher than 16. + * @return string Returns false on failure and the fetched data in the format you specified on success. + * + * Warning If an error occurred, OpenWeatherMap returns data in json format ALWAYS + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getRawDailyForecastData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml', $cnt = 16) + { + if ($cnt > 16) { + throw new \InvalidArgumentException('$cnt must be 16 or below!'); + } + $url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherDailyForecastUrl) . "&cnt=$cnt"; + + return $this->cacheOrFetchResult($url); + } + + /** + * Directly returns the xml/json/html string returned by OpenWeatherMap for the daily forecast. + * + * @param array|int|string $query The place to get weather information for. For possible values see below. + * @param \DateTime $start The \DateTime object of the date to get the first weather information from. + * @param \DateTime|int $endOrCount Can be either a \DateTime object representing the end of the period to + * receive weather history data for or an integer counting the number of + * reports requested. + * @param string $type The period of the weather history requested. Can be either be either "tick", + * "hour" or "day". + * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned. + * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below. + * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details. + * + * @throws \InvalidArgumentException + * + * @return string Returns false on failure and the fetched data in the format you specified on success. + * + * Warning If an error occurred, OpenWeatherMap returns data in json format ALWAYS + * + * There are three ways to specify the place to get weather information for: + * - Use the city name: $query must be a string containing the city name. + * - Use the city id: $query must be an integer containing the city id. + * - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values. + * + * Available languages are (as of 17. July 2013): + * - English - en + * - Russian - ru + * - Italian - it + * - Spanish - sp + * - Ukrainian - ua + * - German - de + * - Portuguese - pt + * - Romanian - ro + * - Polish - pl + * - Finnish - fi + * - Dutch - nl + * - French - fr + * - Bulgarian - bg + * - Swedish - se + * - Chinese Traditional - zh_tw + * - Chinese Simplified - zh_cn + * - Turkish - tr + * + * @api + */ + public function getRawWeatherHistory($query, \DateTime $start, $endOrCount = 1, $type = 'hour', $units = 'imperial', $lang = 'en', $appid = '') + { + if (!in_array($type, array('tick', 'hour', 'day'))) { + throw new \InvalidArgumentException('$type must be either "tick", "hour" or "day"'); + } + + $queryUrl = $this->weatherHistoryUrl . $this->buildQueryUrlParameter($query) . "&start={$start->format('U')}"; + + if ($endOrCount instanceof \DateTime) { + $queryUrl .= "&end={$endOrCount->format('U')}"; + } else if (is_numeric($endOrCount) && $endOrCount > 0) { + $queryUrl .= "&cnt=$endOrCount"; + } else { + throw new \InvalidArgumentException('$endOrCount must be either a \DateTime or a positive integer.'); + } + $queryUrl .= "&type=$type&units=$units&lang=$lang"; + + if (!empty($appid)) { + $queryUrl .= "&APPID=$appid"; + } + + return $this->cacheOrFetchResult($queryUrl); + } + + /** + * Fetches the result or delivers a cached version of the result. + * + * @param $url + * + * @return string + * + * @internal + */ + private function cacheOrFetchResult($url) + { + if ($this->cacheClass !== false) { + /** @var \Cmfcmf\OpenWeatherMap\AbstractCache $cache */ + $cache = $this->cacheClass; + $cache->setSeconds($this->seconds); + if ($cache->isCached($url)) { + return $cache->getCached($url); + } + $result = $this->fetcher->fetch($url); + $cache->setCached($url, $result); + } else { + $result = $this->fetcher->fetch($url); + } + + return $result; + } + + /** + * Build the url to fetch weather data from. + * + * @param $query + * @param $units + * @param $lang + * @param $appid + * @param $mode + * @param string $url The url to prepend. + * + * @return bool|string The fetched url, false on failure. + * + * @internal + */ + private function buildUrl($query, $units, $lang, $appid, $mode, $url) + { + $queryUrl = $this->buildQueryUrlParameter($query); + + $url = $url . "$queryUrl&units=$units&lang=$lang&mode=$mode"; + if (!empty($appid)) { + $url .= "&APPID=$appid"; + } + + return $url; + } + + /** + * Builds the query string for the url. + * + * @param $query + * + * @return string The built query string for the url. + * @throws \InvalidArgumentException If the query parameter is invalid. + * + * @internal + */ + private function buildQueryUrlParameter($query) + { + switch ($query) { + case (is_array($query) && isset($query['lat']) && isset($query['lon']) && is_numeric($query['lat']) && is_numeric($query['lon'])): + return "lat={$query['lat']}&lon={$query['lon']}"; + case (is_numeric($query)): + return "id=$query"; + case (is_string($query)): + return "q=" . urlencode($query); + default: + throw new \InvalidArgumentException('Error: $query has the wrong format. See the documentation of OpenWeatherMap::getRawData() to read about valid formats.'); + } + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/AbstractCache.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/AbstractCache.php new file mode 100644 index 00000000..c9b66ebe --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/AbstractCache.php @@ -0,0 +1,69 @@ +seconds = $seconds; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/CurrentWeather.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/CurrentWeather.php new file mode 100644 index 00000000..7ce2e2a1 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/CurrentWeather.php @@ -0,0 +1,117 @@ +city = new City($xml->city['id'], $xml->city['name'], $xml->city->coord['lon'], $xml->city->coord['lat'], $xml->city->country); + $this->temperature = new Temperature(new Unit($xml->temperature['value'], $xml->temperature['unit']), new Unit($xml->temperature['min'], $xml->temperature['unit']), new Unit($xml->temperature['max'], $xml->temperature['unit'])); + $this->humidity = new Unit($xml->humidity['value'], $xml->humidity['unit']); + $this->pressure = new Unit($xml->pressure['value'], $xml->pressure['unit']); + + // This is kind of a hack, because the units are missing in the xml document. + if ($units == 'metric') { + $windSpeedUnit = 'm/s'; + } else { + $windSpeedUnit = 'mph'; + } + $this->wind = new Wind(new Unit($xml->wind->speed['value'], $windSpeedUnit, $xml->wind->speed['name']), new Unit($xml->wind->direction['value'], $xml->wind->direction['code'], $xml->wind->direction['name'])); + + $this->clouds = new Unit($xml->clouds['value'], null, $xml->clouds['name']); + $this->precipitation = new Unit($xml->precipitation['value'], $xml->precipitation['unit'], $xml->precipitation['mode']); + $utctz = new \DateTimeZone('UTC'); + $this->sun = new Sun(new \DateTime($xml->city->sun['rise'], $utctz), new \DateTime($xml->city->sun['set'], $utctz)); + $this->weather = new WeatherObj($xml->weather['number'], $xml->weather['value'], $xml->weather['icon']); + $this->lastUpdate = new \DateTime($xml->lastupdate['value'], $utctz); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Exception.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Exception.php new file mode 100644 index 00000000..20f3a871 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Exception.php @@ -0,0 +1,27 @@ +city = new City($xml->city['id'], $xml->city['name'], $xml->city->coord['lon'], $xml->city->coord['lat'], $xml->city->country); + + if ($units == 'metric') { + $temperatureUnit = "°C"; + } else { + $temperatureUnit = 'F'; + } + + $xml->temperature['value'] = ($xml->temperature['max'] + $xml->temperature['min']) / 2; + + $this->temperature = new Temperature(new Unit($xml->temperature['value'], $temperatureUnit), new Unit($xml->temperature['min'], $temperatureUnit), new Unit($xml->temperature['max'], $temperatureUnit)); + $this->humidity = new Unit($xml->humidity['value'], $xml->humidity['unit']); + $this->pressure = new Unit($xml->pressure['value'], $xml->pressure['unit']); + + // This is kind of a hack, because the units are missing in the xml document. + if ($units == 'metric') { + $windSpeedUnit = 'm/s'; + } else { + $windSpeedUnit = 'mps'; + } + + $this->wind = new Wind(new Unit($xml->windSpeed['mps'], $windSpeedUnit, $xml->windSpeed['name']), new Unit($xml->windDirection['value'], $xml->windDirection['code'], $xml->windDirection['name'])); + $this->clouds = new Unit($xml->clouds['all'], $xml->clouds['unit'], $xml->clouds['value']); + $this->precipitation = new Unit($xml->precipitation['value'], null, $xml->precipitation['type']); + $this->sun = new Sun(new \DateTime($xml->city->sun['rise']), new \DateTime($xml->city->sun['set'])); + $this->weather = new WeatherObj($xml->symbol['number'], $xml->symbol['name'], $xml->symbol['var']); + $this->lastUpdate = new \DateTime($xml->lastupdate['value']); + + if (isset($xml['from'])) { + $this->time = new Time($xml['from'], $xml['to']); + } else { + $this->time = new Time($xml['day']); + } + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/History.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/History.php new file mode 100644 index 00000000..6601a840 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/History.php @@ -0,0 +1,104 @@ +city = $city; + $this->weather = new Weather($weather['id'], $weather['description'], $weather['icon']); + $this->temperature = new Temperature(new Unit($temperature['now'] - 273.15, "\xB0C"), new Unit($temperature['min'] - 273.15, "\xB0C"), new Unit($temperature['max'] - 273.15, "\xB0C")); + $this->pressure = new Unit($pressure, 'kPa'); + $this->humidity = new Unit($humidity, '%'); + $this->clouds = new Unit($clouds, '%'); + $this->precipitation = new Unit($rain['val'], $rain['unit']); + $this->wind = new Wind(new Unit($wind['speed']), new Unit($wind['deg'])); + $this->time = $time; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/City.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/City.php new file mode 100644 index 00000000..b5dceb2b --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/City.php @@ -0,0 +1,76 @@ +id = (int)$id; + $this->name = isset($name) ? (string)$name : null; + $this->lon = isset($lon) ? (float)$lon : null; + $this->lat = isset($lat) ? (float)$lat : null; + $this->country = isset($country) ? (string)$country : null; + $this->population = isset($population) ? (int)$population : null; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Sun.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Sun.php new file mode 100644 index 00000000..dc0f0104 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Sun.php @@ -0,0 +1,52 @@ +rise = $rise; + $this->set = $set; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Temperature.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Temperature.php new file mode 100644 index 00000000..14146c06 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Temperature.php @@ -0,0 +1,105 @@ +now->__toString(); + } + + /** + * Returns the current temperature's unit. + * + * @return string The current temperature's unit. + */ + public function getUnit() + { + return $this->now->getUnit(); + } + + /** + * Returns the current temperature. + * + * @return string The current temperature. + */ + public function getValue() + { + return $this->now->getValue(); + } + + /** + * Returns the current temperature's description. + * + * @return string The current temperature's description. + */ + public function getDescription() + { + return $this->now->getDescription(); + } + + /** + * Returns the current temperature as formatted string. + * + * @return string The current temperature as formatted string. + */ + public function getFormatted() + { + return $this->now->getFormatted(); + } + + /** + * Create a new temperature object. + * + * @param Unit $now The current temperature. + * @param Unit $min The minimal temperature. + * @param Unit $max The maximal temperature. + * + * @internal + */ + public function __construct(Unit $now, Unit $min, Unit $max) + { + $this->now = $now; + $this->min = $min; + $this->max = $max; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Time.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Time.php new file mode 100644 index 00000000..517b4c30 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Time.php @@ -0,0 +1,65 @@ +format('Y-m-d')); + } else { + $from = ($from instanceof \DateTime) ? $from : new \DateTime((string)$from); + $day = clone $from; + $to = clone $from; + $to = $to->add(new \DateInterval('PT23H59M59S')); + } + + $this->from = $from; + $this->to = $to; + $this->day = $day; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Unit.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Unit.php new file mode 100644 index 00000000..017ff05e --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Unit.php @@ -0,0 +1,128 @@ +value = (float)$value; + $this->unit = (string)$unit; + $this->description = (string)$description; + } + + /** + * Get the value as formatted string with unit. + * + * @return string The value as formatted string with unit. + * + * The unit is not included if it is empty. + */ + public function __toString() + { + return $this->getFormatted(); + } + + /** + * Get the value's unit. + * + * @return string The value's unit. + * + * This also converts 'celsius' to '°C' and 'fahrenheit' to 'F'. + */ + public function getUnit() + { + // Units are inconsistent. Only celsius and fahrenheit are not abbreviated. This check fixes that. + if ($this->unit == 'celsius') { + return "°C"; + } else if ($this->unit == 'fahrenheit') { + return 'F'; + } else { + return $this->unit; + } + } + + /** + * Get the value. + * + * @return float The value. + */ + public function getValue() + { + return $this->value; + } + + /** + * Get the value's description. + * + * @return string The value's description. + */ + public function getDescription() + { + return $this->description; + } + + /** + * Get the value as formatted string with unit. + * + * @return string The value as formatted string with unit. + * + * The unit is not included if it is empty. + */ + public function getFormatted() + { + if ($this->getUnit() != "") { + return "{$this->getValue()} {$this->getUnit()}"; + } else { + return "{$this->getValue()}"; + } + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Weather.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Weather.php new file mode 100644 index 00000000..a9d848eb --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Weather.php @@ -0,0 +1,82 @@ +id = (int)$id; + $this->description = (string)$description; + $this->icon = (string)$icon; + } + + /** + * Get the weather description. + * + * @return string + */ + public function __toString() + { + return $this->description; + } + + /** + * Get the icon url. + * + * @return string The icon url. + */ + public function getIconUrl() + { + return str_replace("%s", $this->icon, $this->iconUrl); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Wind.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Wind.php new file mode 100644 index 00000000..02209600 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Wind.php @@ -0,0 +1,48 @@ +speed = $speed; + $this->direction = $direction; + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherForecast.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherForecast.php new file mode 100644 index 00000000..8230989e --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherForecast.php @@ -0,0 +1,136 @@ +getWeather(). + * + * @see Cmfcmf\OpenWeatherMap::getWeather() The function using it. + */ +class WeatherForecast implements \Iterator +{ + /** + * A city object. + * + * @var Util\City + */ + public $city; + + /** + * A sun object + * + * @var Util\Sun + */ + public $sun; + + /** + * The time of the last update of this weather data. + * + * @var \DateTime + */ + public $lastUpdate; + + /** + * An array of {@link WeatherForecast} objects. + * + * @var array + * + * @see WeatherForecast The WeatherForecast class. + */ + private $forecasts; + + /** + * @internal + */ + private $position = 0; + + /** + * Create a new Forecast object. + * + * @param $xml + * @param string $units + * @param int $days How many days of forecast to receive. + * + * @internal + */ + public function __construct($xml, $units, $days) + { + $this->city = new City(-1, $xml->location->name, $xml->location->location['longitude'], $xml->location->location['latitude'], $xml->location->country); + $this->sun = new Sun(new \DateTime($xml->sun['rise']), new \DateTime($xml->sun['set'])); + $this->lastUpdate = new \DateTime($xml->meta->lastupdate); + + $counter = 0; + foreach ($xml->forecast->time as $time) { + $forecast = new Forecast($time, $units); + $forecast->city = $this->city; + $this->forecasts[] = $forecast; + + $counter++; + // Make sure to only return the requested number of days. + if ($days <= 5 && $counter == $days * 8) { + break; + } else if ($days > 5 && $counter == $days) { + break; + } + } + } + + /** + * @internal + */ + public function rewind() + { + $this->position = 0; + } + + /** + * @internal + */ + public function current() + { + return $this->forecasts[$this->position]; + } + + /** + * @internal + */ + public function key() + { + return $this->position; + } + + /** + * @internal + */ + public function next() + { + ++$this->position; + } + + /** + * @internal + */ + public function valid() + { + return isset($this->forecasts[$this->position]); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherHistory.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherHistory.php new file mode 100644 index 00000000..7ee4084a --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherHistory.php @@ -0,0 +1,118 @@ +city = new OpenWeatherMap\Util\City($weatherHistory['city_id'], (is_string($query)) ? $query : null, (isset($query['lon'])) ? $query['lon'] : null, (isset($query['lat'])) ? $query['lat'] : null, $country, $population); + $this->calctime = $weatherHistory['calctime']; + + foreach ($weatherHistory['list'] as $history) { + if (isset($history['rain'])) { + $units = array_keys($history['rain']); + } else { + $units = array(0 => null); + } + + $this->histories[] = new History($this->city, $history['weather'][0], array('now' => $history['main']['temp'], 'min' => $history['main']['temp_min'], 'max' => $history['main']['temp_max']), $history['main']['pressure'], $history['main']['humidity'], $history['clouds']['all'], isset($history['rain']) ? array('val' => $history['rain'][($units[0])], 'unit' => $units[0]) : null, $history['wind'], \DateTime::createFromFormat('U', $history['dt'])); + } + } + + /** + * @internal + */ + public function rewind() + { + $this->position = 0; + } + + /** + * @internal + */ + public function current() + { + return $this->histories[$this->position]; + } + + /** + * @internal + */ + public function key() + { + return $this->position; + } + + /** + * @internal + */ + public function next() + { + ++$this->position; + } + + /** + * @internal + */ + public function valid() + { + return isset($this->histories[$this->position]); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/Cache.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/Cache.php new file mode 100644 index 00000000..61869f2e --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/Cache.php @@ -0,0 +1,95 @@ +urlToPath($url); + if (!file_exists($path) || filectime($path) + $this->seconds < time()) { + echo "Weather data is NOT cached!\n"; + + return false; + } + + echo "Weather data is cached!\n"; + + return true; + } + + /** + * @inheritdoc + */ + public function getCached($url) + { + return file_get_contents($this->urlToPath($url)); + } + + /** + * @inheritdoc + */ + public function setCached($url, $content) + { + file_put_contents($this->urlToPath($url), $content); + } +} + +// Language of data (try your own language here!): +$lang = 'de'; + +// Units (can be 'metric' or 'imperial' [default]): +$units = 'metric'; + +// Example 1: Use your own cache implementation. Cache for 10 seconds only in this example. +$owm = new OpenWeatherMap(null, new ExampleCache(), 10); + +$weather = $owm->getWeather('Berlin', $units, $lang); +echo "EXAMPLE 1
\n\n\n"; +echo $weather->temperature; diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/CurrentWeather.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/CurrentWeather.php new file mode 100644 index 00000000..46a6c517 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/CurrentWeather.php @@ -0,0 +1,236 @@ +getWeather('Berlin', $units, $lang); +echo "EXAMPLE 1
\n\n\n"; + +// $weather contains all available weather information for Berlin. +// Let's get the temperature: + +// Returns it as formatted string (using __toString()): +echo $weather->temperature; +echo "
\n"; + +// Returns it as formatted string (using a method): +echo $weather->temperature->getFormatted(); +echo "
\n"; + +// Returns the value only: +echo $weather->temperature->getValue(); +echo "
\n"; + +// Returns the unit only: +echo $weather->temperature->getUnit(); +echo "
\n"; + +/** + * In the example above we're using a "shortcut". OpenWeatherMap returns the minimum temperature of a day, + * the maximum temperature and the temperature right now. If you don't specify which temperature you want, it will default + * to the current temperature. See below how to access the other values. Notice that each of them has implemented the methods + * "getFormatted()", "getValue()", "getUnit()". + */ + +// Returns the current temperature: +echo "Current: " . $weather->temperature->now; +echo "
\n"; + +// Returns the minimum temperature: +echo "Minimum: " . $weather->temperature->min; +echo "
\n"; + +// Returns the maximum temperature: +echo "Maximum: " . $weather->temperature->max; +echo "
\n"; + +/** + * When speaking about "current" and "now", this means when the weather data was last updated. You can get this + * via a DateTime object: + */ +echo "Last update: " . $weather->lastUpdate->format('r'); +echo "
\n"; + +// Example 2: Get current pressure and humidity in Hongkong. +$weather = $owm->getWeather('Hongkong', $units, $lang); +echo "

\n\n\nEXAMPLE 2
\n\n\n"; + +/** + * You can use the methods above to only get the value or the unit. + */ + +echo "Pressure: " . $weather->pressure; +echo "
\n"; +echo "Humidity: " . $weather->humidity; +echo "
\n"; + +// Example 3: Get today's sunrise and sunset times. +echo "

\n\n\nEXAMPLE 3
\n\n\n"; + +/** + * These functions return a DateTime object. + */ + +echo "Sunrise: " . $weather->sun->rise->format('r'); +echo "
\n"; +echo "Sunset: " . $weather->sun->set->format('r'); +echo "
\n"; + +// Example 4: Get current temperature from coordinates (Greenland :-) ). +$weather = $owm->getWeather(array('lat' => 77.73038, 'lon' => 41.89604), $units, $lang); +echo "

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

\n\n\nEXAMPLE 5
\n\n\n"; + +echo "City: " . $weather->city->name; +echo "
\n"; + +echo "Temperature: " . $weather->temperature; +echo "
\n"; + +// Example 6: Get information about a city. +$weather = $owm->getWeather('Paris', $units, $lang); +echo "

\n\n\nEXAMPLE 6
\n\n\n"; + +echo "Id: " . $weather->city->id; +echo "
\n"; + +echo "Name: " . $weather->city->name; +echo "
\n"; + +echo "Lon: " . $weather->city->lon; +echo "
\n"; + +echo "Lat: " . $weather->city->lat; +echo "
\n"; + +echo "Country: " . $weather->city->country; +echo "
\n"; + +// Example 7: Get wind information. +echo "

\n\n\nEXAMPLE 7
\n\n\n"; + +echo "Speed: " . $weather->wind->speed; +echo "
\n"; + +echo "Direction: " . $weather->wind->direction; +echo "
\n"; + +/** + * For speed and direction there is a description available, which isn't always translated. + */ + +echo "Speed: " . $weather->wind->speed->getDescription(); +echo "
\n"; + +echo "Direction: " . $weather->wind->direction->getDescription(); +echo "
\n"; + +// Example 8: Get information about the clouds. +echo "

\n\n\nEXAMPLE 8
\n\n\n"; + +// The number in braces seems to be an indicator how cloudy the sky is. +echo "Clouds: " . $weather->clouds->getDescription() . " (" . $weather->clouds . ")"; +echo "
\n"; + +// Example 9: Get information about precipitation. +echo "

\n\n\nEXAMPLE 9
\n\n\n"; + +echo "Precipation: " . $weather->precipitation->getDescription() . " (" . $weather->precipitation . ")"; +echo "
\n"; + +// Example 10: Show copyright notice. WARNING: This is no offical text. This hint was created regarding to http://www.http://openweathermap.org/copyright . +echo "

\n\n\nEXAMPLE 10
\n\n\n"; + +echo $owm::COPYRIGHT; +echo "
\n"; + +// Example 11: Get raw xml data. +echo "

\n\n\nEXAMPLE 11
\n\n\n"; + +echo "
" . htmlspecialchars($owm->getRawWeatherData('Berlin', $units, $lang, null, 'xml')) . "
"; +echo "
\n"; + +// Example 12: Get raw json data. +echo "

\n\n\nEXAMPLE 12
\n\n\n"; + +echo "" . htmlspecialchars($owm->getRawWeatherData('Berlin', $units, $lang, null, 'json')) . ""; +echo "
\n"; + +// Example 13: Get raw html data. +echo "

\n\n\nEXAMPLE 13
\n\n\n"; + +echo $owm->getRawWeatherData('Berlin', $units, $lang, null, 'html'); +echo "
\n"; + +// Example 14: Error handling. +echo "

\n\n\nEXAMPLE 14
\n\n\n"; + +// Try wrong city name. +try { + $weather = $owm->getWeather("ThisCityNameIsNotValidAndDoesNotExist", $units, $lang); +} catch (OWMException $e) { + echo $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} + +// Try invalid $query. +try { + $weather = $owm->getWeather(new \DateTime('now'), $units, $lang); +} catch (\Exception $e) { + echo $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} + +// Full error handling would look like this: +try { + $weather = $owm->getWeather(-1, $units, $lang); +} catch (OWMException $e) { + echo 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} catch (\Exception $e) { + echo 'General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} + +// Example 15: Using an api key: +$owm->getWeather('Berlin', $units, $lang, 'Your-Api-Key-Here'); diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherForecast.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherForecast.php new file mode 100644 index 00000000..833425bb --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherForecast.php @@ -0,0 +1,69 @@ +getWeatherForecast('Berlin', $units, $lang, '', 10); +echo "EXAMPLE 1
\n\n\n"; + +echo "City: " . $forecast->city->name; +echo "
\n"; +echo "LastUpdate: " . $forecast->lastUpdate->format('d.m.Y H:i'); +echo "
\n"; +echo "Sunrise : " . $forecast->sun->rise->format("H:i:s") . " Sunset : " . $forecast->sun->set->format("H:i:s"); +echo "
\n"; +echo "
\n"; + +foreach ($forecast as $weather) { + // Each $weather contains a Cmfcmf\ForecastWeather object which is almost the same as the Cmfcmf\Weather object. + // Take a look into 'Examples_Current.php' to see the available options. + echo "Weather forecast at " . $weather->time->day->format('d.m.Y') . " from " . $weather->time->from->format('H:i') . " to " . $weather->time->to->format('H:i'); + echo "
\n"; + echo $weather->temperature; + echo "
\n"; + echo "---"; + echo "
\n"; +} + +// Example 2: Get forecast for the next 3 days for Berlin. +$forecast = $owm->getWeatherForecast('Berlin', $units, $lang, '', 3); +echo "EXAMPLE 2
\n\n\n"; + +foreach ($forecast as $weather) { + echo "Weather forecast at " . $weather->time->day->format('d.m.Y') . " from " . $weather->time->from->format('H:i') . " to " . $weather->time->to->format('H:i') . "
"; + echo $weather->temperature . "
\n"; + echo "---
\n"; +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherHistory.php b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherHistory.php new file mode 100644 index 00000000..c64ee524 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/Examples/WeatherHistory.php @@ -0,0 +1,43 @@ +getWeatherHistory('Berlin', new \DateTime('2014-01-01'), new \DateTime('now'), 'hour', $units, $lang); + +foreach ($history as $weather) { + echo "Average temperature at " . $weather->time->format('d.m.Y H:i') . ": " . $weather->temperature . "\n\r
"; +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/LICENSE b/curweather/vendor/cmfcmf/openweathermap-php-api/LICENSE new file mode 100644 index 00000000..1d2c3966 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Christian Flach + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/README.md b/curweather/vendor/cmfcmf/openweathermap-php-api/README.md new file mode 100644 index 00000000..ea452611 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/README.md @@ -0,0 +1,83 @@ +OpenWeatherMap-PHP-Api +====================== +A php api to parse weather data from [OpenWeatherMap.org](http://www.OpenWeatherMap.org). This api tries to normalise and abstract the data and remove inconsistencies. + +[![Build Status](https://travis-ci.org/cmfcmf/OpenWeatherMap-PHP-Api.png?branch=master)](https://travis-ci.org/cmfcmf/OpenWeatherMap-PHP-Api)[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/badges/quality-score.png?s=f31ca08aa8896416cf162403d34362f0a5da0966)](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/)[![Code Coverage](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/badges/coverage.png?s=65153e7cfb13e050d734c645e38f2dd7ea7a6860)](https://scrutinizer-ci.com/g/cmfcmf/OpenWeatherMap-PHP-Api/) +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/0addfb24-e2b4-4feb-848e-86b2078ca104/big.png)](https://insight.sensiolabs.com/projects/0addfb24-e2b4-4feb-848e-86b2078ca104) +----------- + +For example code and how to use this api, please take a look into `Examples_*.php` files and run them in your browser. +- `Examples_Current.php` Shows how to receive the current weather. +- `Examples_Forecast.php` Shows how to receive weather forecasts. +- [*NEW*] `Examples_History.php` Shows how to receive weather history. +- `Examples_Cache.php` Shows how to implement a cache. + +**Notice:** This api is not made by OpenWeatherMap, nor their official php api. + +Contribute! +=========== +I'm very happy if you open **pull requests** or **issues** to help making this API **more awesome**. + +Installation +============ +This library can be found on [Packagist](https://packagist.org/packages/cmfcmf/openweathermap-php-api). +The recommended way to install this is through [composer](http://getcomposer.org). + +Edit your `composer.json` and add: + +```json +{ + "require": { + "cmfcmf/openweathermap-php-api": "~2.0" + } +} +``` + +And install dependencies: + +```bash +$ curl -sS https://getcomposer.org/installer | php +$ php composer.phar install +``` + + +Example call +============ +```php +getWeather('Berlin', $units, $lang); +} catch(OWMException $e) { + echo 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} catch(\Exception $e) { + echo 'General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').'; + echo "
\n"; +} + +echo $weather->temperature; +``` + +License +======= +MIT — Please see the [LICENSE file](https://github.com/Cmfcmf/OpenWeatherMap-PHP-Api/blob/master/LICENSE) distributed with this source code for further information regarding copyright and licensing. + +**Please check out the following links to read about the usage policies and the license of OpenWeatherMap before using the service.** +- [OpenWeatherMap.org](http://www.OpenWeatherMap.org) +- [OpenWeatherMap.org/terms](http://www.OpenWeatherMap.org/terms) +- [OpenWeatherMap.org/appid](http://www.OpenWeatherMap.org/appid) diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/composer.json b/curweather/vendor/cmfcmf/openweathermap-php-api/composer.json new file mode 100644 index 00000000..687cd4f4 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/composer.json @@ -0,0 +1,30 @@ +{ + "name": "cmfcmf/openweathermap-php-api", + "description": "A php api to parse weather data from OpenWeatherMap.org. This api tries to normalise and abstract the data and remove inconsistencies.", + "keywords": ["weather", "OpenWeatherMap", "weather api"], + "homepage": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api", + "license": "MIT", + "authors": [ + { + "name": "Christian Flach (cmfcmf)", + "email": "cmfcmf.flach@gmail.com", + "homepage": "http://cmfcmf.github.io", + "role": "Developer" + } + ], + "support": { + "issues": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/issues", + "source": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api.git" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.7.0" + }, + "autoload": { + "psr-0": { + "Cmfcmf\\": "" + } + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/composer.lock b/curweather/vendor/cmfcmf/openweathermap-php-api/composer.lock new file mode 100644 index 00000000..5ef16474 --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/composer.lock @@ -0,0 +1,973 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "23a2734069dc5af143bb0e0a09160885", + "packages": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14 21:17:01" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2015-02-03 12:10:50" + }, + { + "name": "phpspec/prophecy", + "version": "v1.4.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2015-04-27 22:15:08" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.1.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "631e365cf26bb2c078683e8d9bcf8bc631ac4d44" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/631e365cf26bb2c078683e8d9bcf8bc631ac4d44", + "reference": "631e365cf26bb2c078683e8d9bcf8bc631ac4d44", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-06-19 07:11:55" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2015-04-02 05:19:05" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/83fe1bdc5d47658b727595c14da140da92b3d66d", + "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2015-06-13 07:35:30" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-06-19 03:43:16" + }, + { + "name": "phpunit/phpunit", + "version": "4.7.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "e5f851f324f7add846316f39e668e9deac97a103" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e5f851f324f7add846316f39e668e9deac97a103", + "reference": "e5f851f324f7add846316f39e668e9deac97a103", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "~1.3,>=1.3.1", + "phpunit/php-code-coverage": "~2.1", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": ">=1.0.6", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.2", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2015-06-18 13:33:26" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/92408bb1968a81b3217a6fdf6c1a198da83caa35", + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-06-11 15:55:48" + }, + { + "name": "sebastian/comparator", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-01-29 16:28:08" + }, + { + "name": "sebastian/diff", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-02-22 15:13:53" + }, + { + "name": "sebastian/environment", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2015-01-01 10:01:08" + }, + { + "name": "sebastian/exporter", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "84839970d05254c73cde183a721c7af13aede943" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-01-27 07:23:06" + }, + { + "name": "sebastian/global-state", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2014-10-06 09:23:50" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "sebastian/version", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-02-24 06:35:25" + }, + { + "name": "symfony/yaml", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/9808e75c609a14f6db02f70fccf4ca4aab53c160", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-06-10 15:30:22" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.3.0" + }, + "platform-dev": [] +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/phpunit.xml.dist b/curweather/vendor/cmfcmf/openweathermap-php-api/phpunit.xml.dist new file mode 100644 index 00000000..cceb148d --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + + + + + ./tests + + + + + + ./ + + ./ + ./ + ./vendor + + + + diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/CurlFetcherTest.php b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/CurlFetcherTest.php new file mode 100644 index 00000000..7f2cfe9a --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/CurlFetcherTest.php @@ -0,0 +1,53 @@ +fetch('http://notexisting.example.com'); + + $this->assertSame(false, $content); + } + + public function testEmptyUrl() + { + $fetcher = new CurlFetcher(); + + $content = $fetcher->fetch(''); + + $this->assertSame(false, $content); + } + + public function testValidUrl() + { + $fetcher = new CurlFetcher(); + + $content = $fetcher->fetch('http://httpbin.org/html'); + + $this->assertContains('Herman Melville', $content); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/FileGetContentsFetcherTest.php b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/FileGetContentsFetcherTest.php new file mode 100644 index 00000000..f556c09f --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Fetcher/FileGetContentsFetcherTest.php @@ -0,0 +1,59 @@ +markTestSkipped('"allow_url_fopen" is set to off.'); + } + } + + /** + * @expectedException \PHPUnit_Framework_Error_Warning + */ + public function testInvalidUrl() + { + $fetcher = new FileGetContentsFetcher(); + + $fetcher->fetch('http://notexisting.example.com'); + } + + /** + * @expectedException \PHPUnit_Framework_Error_Warning + */ + public function testEmptyUrl() + { + $fetcher = new FileGetContentsFetcher(); + + $fetcher->fetch(''); + } + + public function testValidUrl() + { + $fetcher = new FileGetContentsFetcher(); + + $content = $fetcher->fetch('http://httpbin.org/html'); + + $this->assertContains('Herman Melville', $content); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/SunTest.php b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/SunTest.php new file mode 100644 index 00000000..516a796d --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/SunTest.php @@ -0,0 +1,62 @@ +givenThereIsASunObject($rise, $set); + + $this->assertSame($rise, $this->sun->rise); + } + + public function testSunSet() + { + $rise = new \DateTime('2014-01-01 08:00:00'); + $set = new \DateTime('2014-01-01 20:00:00'); + + $this->givenThereIsASunObject($rise, $set); + + $this->assertSame($set, $this->sun->set); + } + + + private function givenThereIsASunObject($rise, $set) + { + $this->sun = new Sun($rise, $set); + } + + /** + * @expectedException \LogicException + */ + public function testSunSetBeforeSunRiseException() + { + $rise = new \DateTime('2014-01-01 08:00:00'); + $set = new \DateTime('2014-01-01 7:00:00'); + + $this->givenThereIsASunObject($rise, $set); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/UnitTest.php b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/UnitTest.php new file mode 100644 index 00000000..bd85e16f --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/UnitTest.php @@ -0,0 +1,159 @@ +givenThereIsAUnitWithValue(self::POSITIVE_INT_VALUE); + + $this->assertSame((float)self::POSITIVE_INT_VALUE, $this->unit->getValue()); + } + + public function testGetValueWithPositiveFloatValue() + { + $this->givenThereIsAUnitWithValue(self::POSITIVE_FLOAT_VALUE); + + $this->assertSame(self::POSITIVE_FLOAT_VALUE, $this->unit->getValue()); + } + + public function testGetValueWithNegativeIntValue() + { + $this->givenThereIsAUnitWithValue(self::NEGATIVE_INT_VALUE); + + $this->assertSame((float)self::NEGATIVE_INT_VALUE, $this->unit->getValue()); + } + + public function testGetValueWithNegativeFloatValue() + { + $this->givenThereIsAUnitWithValue(self::NEGATIVE_FLOAT_VALUE); + + $this->assertSame(self::NEGATIVE_FLOAT_VALUE, $this->unit->getValue()); + } + + public function testGetValueWithZeroIntValue() + { + $this->givenThereIsAUnitWithValue(self::ZERO_INT_VALUE); + + $this->assertSame((float)self::ZERO_INT_VALUE, $this->unit->getValue()); + } + + public function testGetValueWithZeroFloatValue() + { + $this->givenThereIsAUnitWithValue(self::ZERO_FLOAT_VALUE); + + $this->assertSame(self::ZERO_FLOAT_VALUE, $this->unit->getValue()); + } + + private function givenThereIsAUnitWithValue($value, $unit = null) + { + $this->unit = $unit === null ? new Unit($value) : new Unit($value, $unit); + } + + public function testGetUnitWithEmptyUnit() + { + $this->givenThereIsAUnitWithUnit(""); + + $this->assertSame("", $this->unit->getUnit()); + } + + public function testGetUnitWithStringAsUnit() + { + $this->givenThereIsAUnitWithUnit("Hey! I'm cmfcmf"); + + $this->assertSame("Hey! I'm cmfcmf", $this->unit->getUnit()); + } + + public function testCelsiusFixture() + { + $this->givenThereIsAUnitWithUnit("celsius"); + + $this->assertSame("°C", $this->unit->getUnit()); + } + + public function testFahrenheitFixture() + { + $this->givenThereIsAUnitWithUnit("fahrenheit"); + + $this->assertSame("F", $this->unit->getUnit()); + } + + private function givenThereIsAUnitWithUnit($unit) + { + $this->unit = new Unit(0, $unit); + } + + public function testGetDescriptionWithEmptyDescription() + { + $this->givenThereIsAUnitWithDescription(""); + + $this->assertSame("", $this->unit->getDescription()); + } + + public function testGetDescriptionWithStringAsDescription() + { + $this->givenThereIsAUnitWithDescription("Hey! I'm cmfcmf"); + + $this->assertSame("Hey! I'm cmfcmf", $this->unit->getDescription()); + } + + private function givenThereIsAUnitWithDescription($description) + { + $this->unit = new Unit(0, "", $description); + } + + public function testGetFormattedWithoutUnit() + { + $this->givenThereIsAUnitWithValue(self::POSITIVE_INT_VALUE); + + $this->assertEquals(self::POSITIVE_INT_VALUE, $this->unit->getFormatted()); + $this->assertEquals($this->unit->getValue(), $this->unit->getFormatted()); + } + + public function testGetFormattedWithUnit() + { + $this->givenThereIsAUnitWithValue(self::POSITIVE_INT_VALUE, 'K'); + + $this->assertEquals(self::POSITIVE_INT_VALUE . ' K', $this->unit->getFormatted()); + $this->assertEquals($this->unit->getValue() . ' ' . $this->unit->getUnit(), $this->unit->getFormatted()); + } + + public function testToString() + { + $this->givenThereIsAUnitWithValue(self::POSITIVE_INT_VALUE, 'K'); + + $this->assertEquals($this->unit->getFormatted(), $this->unit); + } +} diff --git a/curweather/vendor/cmfcmf/openweathermap-php-api/tests/bootstrap.php b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/bootstrap.php new file mode 100644 index 00000000..a844cc5a --- /dev/null +++ b/curweather/vendor/cmfcmf/openweathermap-php-api/tests/bootstrap.php @@ -0,0 +1,12 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0 class loader + * + * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + + private $classMapAuthoritative = false; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-0 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative) { + return false; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/curweather/vendor/composer/autoload_classmap.php b/curweather/vendor/composer/autoload_classmap.php new file mode 100644 index 00000000..7a91153b --- /dev/null +++ b/curweather/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($vendorDir . '/cmfcmf/openweathermap-php-api'), +); diff --git a/curweather/vendor/composer/autoload_psr4.php b/curweather/vendor/composer/autoload_psr4.php new file mode 100644 index 00000000..b265c64a --- /dev/null +++ b/curweather/vendor/composer/autoload_psr4.php @@ -0,0 +1,9 @@ + $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(true); + + return $loader; + } +} + +function composerRequire6bf0e42f34a65c53928f3dc22e5b93d3($file) +{ + require $file; +} diff --git a/curweather/vendor/composer/installed.json b/curweather/vendor/composer/installed.json new file mode 100644 index 00000000..cdba81cc --- /dev/null +++ b/curweather/vendor/composer/installed.json @@ -0,0 +1,51 @@ +[ + { + "name": "cmfcmf/openweathermap-php-api", + "version": "v2.0.7", + "version_normalized": "2.0.7.0", + "source": { + "type": "git", + "url": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api.git", + "reference": "ab387ebcad332b1e58be443f760e1235e7976443" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cmfcmf/OpenWeatherMap-PHP-Api/zipball/ab387ebcad332b1e58be443f760e1235e7976443", + "reference": "ab387ebcad332b1e58be443f760e1235e7976443", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.7.0" + }, + "time": "2015-06-23 21:07:37", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Cmfcmf\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Flach (cmfcmf)", + "email": "cmfcmf.flach@gmail.com", + "homepage": "http://cmfcmf.github.io", + "role": "Developer" + } + ], + "description": "A php api to parse weather data from OpenWeatherMap.org. This api tries to normalise and abstract the data and remove inconsistencies.", + "homepage": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api", + "keywords": [ + "OpenWeatherMap", + "weather", + "weather api" + ] + } +] -- 2.39.5