You are here

protected function WeatherHourlyBlock::getTemperature in Wunderground weather 8

Get a formatted temperature string.

Parameters

\stdClass $hour: The hour for that holds the temperature variable.

Return value

string A formatted temperature

File

src/Plugin/Block/WeatherHourlyBlock.php, line 286
Contains \Drupal\wunderground_weather\Plugin\Block\WeatherHourlyBlock.

Class

WeatherHourlyBlock
Provides a with an hourly weather forecast.

Namespace

Drupal\wunderground_weather\Plugin\Block

Code

protected function getTemperature(\stdClass $hour) {
  $config = $this
    ->getConfiguration();
  $temp = $config['temperature_scale'] === 'c' ? $hour->temp->metric : $hour->temp->english;
  return $temp . '°' . strtoupper($config['temperature_scale']);
}