Temperature.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 temperature class representing a temperature object.
  20. */
  21. class Temperature
  22. {
  23. /**
  24. * @var Unit The current temperature.
  25. */
  26. public $now;
  27. /**
  28. * @var Unit The minimal temperature.
  29. */
  30. public $min;
  31. /**
  32. * @var Unit The maximal temperature.
  33. */
  34. public $max;
  35. /**
  36. * @var Unit The day temperature. Might not be null.
  37. */
  38. public $day;
  39. /**
  40. * @var Unit The morning temperature. Might not be null.
  41. */
  42. public $morning;
  43. /**
  44. * @var Unit The evening temperature. Might not be null.
  45. */
  46. public $evening;
  47. /**
  48. * @var Unit The night temperature. Might not be null.
  49. */
  50. public $night;
  51. /**
  52. * Returns the current temperature as formatted string.
  53. *
  54. * @return string The current temperature as a formatted string.
  55. */
  56. public function __toString()
  57. {
  58. return $this->now->__toString();
  59. }
  60. /**
  61. * Returns the current temperature's unit.
  62. *
  63. * @return string The current temperature's unit.
  64. */
  65. public function getUnit()
  66. {
  67. return $this->now->getUnit();
  68. }
  69. /**
  70. * Returns the current temperature.
  71. *
  72. * @return string The current temperature.
  73. */
  74. public function getValue()
  75. {
  76. return $this->now->getValue();
  77. }
  78. /**
  79. * Returns the current temperature's description.
  80. *
  81. * @return string The current temperature's description.
  82. */
  83. public function getDescription()
  84. {
  85. return $this->now->getDescription();
  86. }
  87. /**
  88. * Returns the current temperature as formatted string.
  89. *
  90. * @return string The current temperature as formatted string.
  91. */
  92. public function getFormatted()
  93. {
  94. return $this->now->getFormatted();
  95. }
  96. /**
  97. * Create a new temperature object.
  98. *
  99. * @param Unit $now The current temperature.
  100. * @param Unit $min The minimal temperature.
  101. * @param Unit $max The maximal temperature.
  102. * @param Unit $day The day temperature. Might not be null.
  103. * @param Unit $morning The morning temperature. Might not be null.
  104. * @param Unit $evening The evening temperature. Might not be null.
  105. * @param Unit $night The night temperature. Might not be null.
  106. *
  107. * @internal
  108. */
  109. public function __construct(Unit $now, Unit $min, Unit $max, Unit $day = null, Unit $morning = null, Unit $evening = null, Unit $night = null)
  110. {
  111. $this->now = $now;
  112. $this->min = $min;
  113. $this->max = $max;
  114. $this->day = $day;
  115. $this->morning = $morning;
  116. $this->evening = $evening;
  117. $this->night = $night;
  118. }
  119. }