code: public function encode($data): string
      {
          $result = json_encode($data);
  
          if (json_last_error() === JSON_ERROR_NONE) {
              return $result;
          }
  
          throw new Exception(json_last_error_msg());
      }
docs: {@inheritdoc}