City.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * OpenWeatherMap-PHP-API — A php api to parse weather data from http://www.OpenWeatherMap.org .
  4. *
  5. * @license MIT
  6. *
  7. * Please see the LICENSE file distributed with this source code for further
  8. * information regarding copyright and licensing.
  9. *
  10. * Please visit the following links to read about the usage policies and the license of
  11. * OpenWeatherMap before using this class:
  12. *
  13. * @see http://www.OpenWeatherMap.org
  14. * @see http://www.OpenWeatherMap.org/terms
  15. * @see http://openweathermap.org/appid
  16. */
  17. namespace Cmfcmf\OpenWeatherMap\Util;
  18. /**
  19. * The city class representing a city object.
  20. */
  21. class City extends Location
  22. {
  23. /**
  24. * @var int The city id.
  25. */
  26. public $id;
  27. /**
  28. * @var string The name of the city.
  29. */
  30. public $name;
  31. /**
  32. * @var string The abbreviation of the country the city is located in.
  33. */
  34. public $country;
  35. /**
  36. * @var int The city's population
  37. */
  38. public $population;
  39. /**
  40. * Create a new city object.
  41. *
  42. * @param int $id The city id.
  43. * @param string $name The name of the city.
  44. * @param float $lat The latitude of the city.
  45. * @param float $lon The longitude of the city.
  46. * @param string $country The abbreviation of the country the city is located in
  47. * @param int $population The city's population.
  48. *
  49. * @internal
  50. */
  51. public function __construct($id, $name = null, $lat = null, $lon = null, $country = null, $population = null)
  52. {
  53. $this->id = (int)$id;
  54. $this->name = isset($name) ? (string)$name : null;
  55. $this->country = isset($country) ? (string)$country : null;
  56. $this->population = isset($population) ? (int)$population : null;
  57. parent::__construct($lat, $lon);
  58. }
  59. }