Pressure.php 1019 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Yr\Forecast\Tabular\Time;
  3. /**
  4. * Airpressure
  5. *
  6. * @author Joachim M. Giæver (joachim[]giaever.org)
  7. * @todo Conversion
  8. */
  9. class Pressure extends AbstractUnit {
  10. const NORMAL_PRESSURE = 1015.0;
  11. /**
  12. * @param \SimpleXMLElement $xml XML containing the pressure
  13. */
  14. public function __construct(\SimpleXMLElement $xml) {
  15. parent::__construct(
  16. (float)$xml['value'],
  17. (string)$xml['unit']
  18. );
  19. }
  20. /**
  21. * Check if the pressure is below normal pressure
  22. *
  23. * @return bool
  24. */
  25. public function isLowPressure(): bool {
  26. return $this->getValue() < self::NORMAL_PRESSURE;
  27. }
  28. /**
  29. * Check if the pressure is above normal pressure
  30. *
  31. * @return bool
  32. */
  33. public function isHighPressure(): bool {
  34. return $this->getValue() > self::NORMAL_PRESSURE;
  35. }
  36. public function thresholdDiff(DiffInterface $e): bool {
  37. return $this->isLowPressure() != $e->isLowPressure();
  38. }
  39. }