code: public function encoder($options = 0, $depth = 512)
      {
          if ($options instanceof Encoding) {
              $options = $options->getOptions();
          }
  
          if (!$options instanceof EncoderOptions) {
              $options = new EncoderOptions($options, $this->getUrl()->toString(), $depth);
          }
  
          return $this->factory->createEncoder($this->getContainer(), $options);
      }
docs: Create an encoder for the API.
  
  @param int|EncoderOptions|Encoding $options
  @param int $depth
  @return SerializerInterface