code: public function encode($data)
      {
          if (is_array($data)) {
              $encodedData = [
                  self::STORAGE_KEY_FORMAT => $this->getFormat(),
                  self::STORAGE_KEY_VERSION => $this->getVersion(),
              ];
  
              foreach ($data as $key => &$value) {
                  if ($value instanceof TimeLine) {
                      $encodedData[$key] = $this->packTimeLine($value);
                  } else {
                      $encodedData[$key] = &$value;
                  }
              }
  
              return json_encode($encodedData);
          }
  
          return json_encode($data);
      }
docs: Encode a dataset with the managed format.
  @param mixed $data
  @return string