Browse Source

Added JsonSer. to AbstractUnit

Joachim M. Giæver 4 years ago
parent
commit
0827b5813d
1 changed files with 5 additions and 1 deletions
  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(