code: public function serialize($data)
      {
          if (!$this->serializer || \is_numeric($data) || \is_string($data) || empty($data) || $data instanceof \JsonSerializable) {
              return $data;
          }
  
          return $this->getSerializer()->serialize($data);
      }
docs: Serialize data.
  
  @param mixed $data
  
  @return null|array|int|\JsonSerializable|string