Browse Source

Fixed missing self:: on const

Joachim M. Giæver 4 years ago
parent
commit
fecd60bee9

+ 1 - 0
index.php

@@ -48,6 +48,7 @@ class TextForcast {
                         $str[] = ($prev == null ? ' ' : ', ') . $data->getName();
                         break;
                     case Temperature::class:
+                        $data = $data->convertTo(Temperature::UNIT_KELVIN);
                         $str[] = ($prev == null ? ' ' : ', ') . sprintf('%d %s', $data->getValue(), $data->getDegree());
                         break;
                     default:

+ 3 - 3
src/Yr/Forecast/Tabular/Time/Temperature.php

@@ -26,15 +26,15 @@ class Temperature extends AbstractUnit implements ConvertableInterface {
      * {@inheritDoc}
      * @todo support conversion from other types, not just celcius
      */
-    public function convertTo(string $unit): self {
+    public function convertTo(string $unit): ConvertableInterface {
         switch ($unit) {
-        case UNIT_FAHRENHEIT:
+        case self::UNIT_FAHRENHEIT:
             return $this->mul(new CustomUnit(
                 9/5, $unit
             ))->add(new CustomUnit(
                 32, $unit
             ));
-        case UNIT_KELVIN:
+        case self::UNIT_KELVIN:
             return $this->add(new CustomUnit(
                 273.15, $unit
             ));

+ 1 - 1
src/Yr/Forecast/Tabular/Time/WindSpeed.php

@@ -32,7 +32,7 @@ class WindSpeed extends AbstractUnit implements ConvertableInterface {
      * {@inheritDoc}
      * @todo Support conversion from other types, not just mps
      */
-    public function convertTo(string $unit): self {
+    public function convertTo(string $unit): ConvertableInterface {
         switch ($unit) {
         case self::UNIT_KNOTS:
             return $this->mul(new CustomUnit(1.9438445, $unit))->setName($this->getName());