Skip to content

Commit f4fc509

Browse files
committed
Merge pull request #71 from cmfcmf/release-2.1
Release 2.1
2 parents fa3f4f7 + 1ce83fb commit f4fc509

14 files changed

+169
-66
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ before_install:
2323
- sudo socat TCP-LISTEN:80,fork TCP:184.170.226.124:3128 > /tmp/socat.log 2>&1 &
2424

2525
install:
26-
- composer install --dev
26+
- composer install
2727

2828
script:
2929
- phpunit --coverage-text --coverage-clover=coverage.clover

Cmfcmf/OpenWeatherMap/Forecast.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct(\SimpleXMLElement $xml, $units)
5454
$temperatureUnit = 'F';
5555
}
5656

57-
$xml->temperature['value'] = ($xml->temperature['max'] + $xml->temperature['min']) / 2;
57+
$xml->temperature['value'] = round((floatval($xml->temperature['max']) + floatval($xml->temperature['min'])) / 2, 2);
5858

5959
$this->temperature = new Temperature(new Unit($xml->temperature['value'], $temperatureUnit), new Unit($xml->temperature['min'], $temperatureUnit), new Unit($xml->temperature['max'], $temperatureUnit), new Unit($xml->temperature['day'], $temperatureUnit), new Unit($xml->temperature['morn'], $temperatureUnit), new Unit($xml->temperature['eve'], $temperatureUnit), new Unit($xml->temperature['night'], $temperatureUnit));
6060
$this->humidity = new Unit($xml->humidity['value'], $xml->humidity['unit']);

Cmfcmf/OpenWeatherMap/WeatherForecast.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class WeatherForecast implements \Iterator
7474
*/
7575
public function __construct($xml, $units, $days)
7676
{
77-
$this->city = new City(-1, $xml->location->name, $xml->location->location['longitude'], $xml->location->location['latitude'], $xml->location->country);
77+
$this->city = new City($xml->location->location['geobaseid'], $xml->location->name, $xml->location->location['longitude'], $xml->location->location['latitude'], $xml->location->country);
7878
$this->sun = new Sun(new \DateTime($xml->sun['rise']), new \DateTime($xml->sun['set']));
7979
$this->lastUpdate = new \DateTime($xml->meta->lastupdate);
8080

Examples/Cache.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@
1818
use Cmfcmf\OpenWeatherMap;
1919
use Cmfcmf\OpenWeatherMap\AbstractCache;
2020

21-
if (file_exists('../vendor/autoload.php')) {
22-
// Library is not part of a project. "composer install" was executed directly on this library's composer file.
23-
require('../vendor/autoload.php');
24-
} else {
25-
// Library is part of a project.
26-
/** @noinspection PhpIncludeInspection */
27-
require('../../../autoload.php');
28-
}
21+
require_once __DIR__ . '/bootstrap.php';
2922

3023
/**
3124
* Example cache implementation.
@@ -81,10 +74,6 @@ public function setCached($url, $content)
8174
}
8275
}
8376

84-
// Load the api key.
85-
$ini = parse_ini_file('ApiKey.ini');
86-
$myApiKey = $ini['api_key'];
87-
8877
// Language of data (try your own language here!):
8978
$lang = 'de';
9079

Examples/CurrentWeather.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,7 @@
1717
use Cmfcmf\OpenWeatherMap;
1818
use Cmfcmf\OpenWeatherMap\Exception as OWMException;
1919

20-
if (file_exists('../vendor/autoload.php')) {
21-
// Library is not part of a project. "composer install" was executed directly on this library's composer file.
22-
require '../vendor/autoload.php';
23-
} else {
24-
// Library is part of a project.
25-
/** @noinspection PhpIncludeInspection */
26-
require '../../../autoload.php';
27-
}
28-
29-
// Load the api key.
30-
$ini = parse_ini_file('ApiKey.ini');
31-
$myApiKey = $ini['api_key'];
20+
require_once __DIR__ . '/bootstrap.php';
3221

3322
// Language of data (try your own language here!):
3423
$lang = 'de';

Examples/WeatherForecast.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,7 @@
1717

1818
use Cmfcmf\OpenWeatherMap;
1919

20-
if (file_exists('../vendor/autoload.php')) {
21-
// Library is not part of a project. "composer install" was executed directly on this library's composer file.
22-
require('../vendor/autoload.php');
23-
} else {
24-
// Library is part of a project.
25-
/** @noinspection PhpIncludeInspection */
26-
require('../../../autoload.php');
27-
}
28-
29-
// Load the api key.
30-
$ini = parse_ini_file('ApiKey.ini');
31-
$myApiKey = $ini['api_key'];
20+
require_once __DIR__ . '/bootstrap.php';
3221

3322
// Language of data (try your own language here!):
3423
$lang = 'de';

Examples/WeatherHistory.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,7 @@
1616
*/
1717
use Cmfcmf\OpenWeatherMap;
1818

19-
if (file_exists('../vendor/autoload.php')) {
20-
// Library is not part of a project. "composer install" was executed directly on this library's composer file.
21-
require '../vendor/autoload.php';
22-
} else {
23-
// Library is part of a project.
24-
/** @noinspection PhpIncludeInspection */
25-
require '../../../autoload.php';
26-
}
27-
28-
// Load the api key.
29-
$ini = parse_ini_file('ApiKey.ini');
30-
$myApiKey = $ini['api_key'];
19+
require_once __DIR__ . '/bootstrap.php';
3120

3221
// Language of data (try your own language here!):
3322
$lang = 'en';

Examples/bootstrap.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
call_user_func(function () {
4+
if (!is_file($autoloadFile = __DIR__ . '/../vendor/autoload.php')) {
5+
throw new \RuntimeException('Did not find vendor/autoload.php. Did you run "composer install --dev"?');
6+
}
7+
8+
/** @noinspection PhpIncludeInspection */
9+
require_once $autoloadFile;
10+
11+
ini_set('date.timezone', 'Europe/Berlin');
12+
});
13+
14+
15+
// Load the api key.
16+
$ini = parse_ini_file('ApiKey.ini');
17+
$myApiKey = $ini['api_key'];

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Installation
1414
============
1515
This library can be found on [Packagist](https://packagist.org/packages/cmfcmf/openweathermap-php-api).
1616
The recommended way to install and use this is through [Composer](http://getcomposer.org).
17-
Execute `composer require "cmfcmf/openweathermap-php-api": "~2.0"` in your
18-
project root.
17+
18+
composer require "cmfcmf/openweathermap-php-api"
19+
1920

2021
Example call
2122
============

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"php": ">=5.3.0"
2121
},
2222
"autoload": {
23-
"psr-0": {
24-
"Cmfcmf\\": ""
23+
"psr-4": {
24+
"Cmfcmf\\": "Cmfcmf"
2525
}
2626
}
2727
}

0 commit comments

Comments
 (0)