public function testWeatherInPrague()
 {
     $weather = new OpenWeather(null, $_ENV['WEATHER_API']);
     $forecast = $weather->getForecast("Prague, Czech republic");
     $this->assertInternalType('float', $forecast->getTemperature());
     $this->assertInstanceOf('\\DateTime', $forecast->getSunset());
 }
Exemple #2
0
<?php

require "../vendor/autoload.php";
use Defr\OpenWeather;
$weather = new OpenWeather();
$forecast = $weather->getForecast();
echo "<h1>" . $forecast->getCity() . "</h1>";
echo sprintf('<p>Teplota: %s °C<br>Počasí: %s<br>Východ slunce: %s<br>Západ slunce: %s<br>%s<p>', $forecast->getTemperature(), $forecast->getDescription(), $forecast->getSunrise()->format('H:i:s'), $forecast->getSunset()->format('H:i:s'), $forecast->getImageHtmlTag());