Explorar el Código

Added JsonSer. to AbstractUnit

Joachim M. Giæver hace 5 años
padre
commit
0827b5813d
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      src/Yr/Forecast/Tabular/Time/AbstractUnit.php

+ 5 - 1
src/Yr/Forecast/Tabular/Time/AbstractUnit.php

@@ -5,7 +5,7 @@ namespace App\Yr\Forecast\Tabular\Time;
 /**
  * Time-object entity should inherit this
  */
-abstract class AbstractUnit implements DiffInterface {
+abstract class AbstractUnit implements DiffInterface, \JsonSerializable {
     const DEFAULT_VARIANCE = 2;
 
     private $value = 0;
@@ -140,6 +140,10 @@ abstract class AbstractUnit implements DiffInterface {
         return 0;
     }
 
+    public function jsonSerialize(): string {
+        return $this->__toString();
+    }
+
     public function __toString(): string {
         return sprintf(
             "%s: %01.1f %s", basename(str_replace(