Location.php 613 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Yr\Forecast;
  3. final class Location {
  4. private $name;
  5. private $type;
  6. private $country;
  7. private $tz;
  8. private $loc = [];
  9. public function __construct(\SimpleXMLElement $xml) {
  10. $this->name = (string)$xml->name;
  11. $this->type = (string)$xml->type;
  12. $this->country = (string)$xml->country;
  13. $this->tz = (string)$xml->timezone['id'];
  14. $this->loc = [
  15. 'lat' => (float)$xml->location['latitude'],
  16. 'lng' => (float)$xml->location['longitude'],
  17. 'alt' => (float)$xml->location['altitude']
  18. ];
  19. }
  20. }
  21. ?>