123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App\Yr\Forecast\Tabular\Time;
- /**
- * Airpressure
- *
- * @author Joachim M. Giæver (joachim[]giaever.org)
- */
- class Pressure extends AbstractUnit {
- const NORMAL_PRESSURE = 1015.0;
- /**
- * @param \SimpleXMLElement $xml XML containing the pressure
- */
- public function __construct(\SimpleXMLElement $xml) {
- parent::__construct(
- (float)$xml['value'],
- (string)$xml['unit']
- );
- }
- /**
- * Check if the pressure is below normal pressure
- *
- * @return bool
- */
- public function isLowPressure(): bool {
- return $this->getValue() < self::NORMAL_PRESSURE;
- }
- /**
- * Check if the pressure is above normal pressure
- *
- * @return bool
- */
- public function isHighPressure(): bool {
- return $this->getValue() > self::NORMAL_PRESSURE;
- }
- /**
- * {@inheritDoc}
- */
- public function diff(DiffInterface $d): int {
- if ($diff = parent::diff($d))
- return $this->isLowPressure() == $d->isLowPressure() ? 0 : 1;
- return 0;
- }
- }
|