code: public function getWriterFactory()
      {
          if (!$this->writerFactory) {
              $xmlFormatter = new Xml();
              $jsonFormatter = new Json();
              $this->writerFactory = new WriterFactory([
                  // xml
                  'xml' => $xmlFormatter,
                  'text/xml' => $xmlFormatter,
                  'application/xml' => $xmlFormatter,
                  // json
                  'json' => $jsonFormatter,
                  'application/json' => $jsonFormatter,
              ]);
          }
          return $this->writerFactory;
      }
docs: Get the writer factory.
  
  If none is set it will create a default format factory for xml and json
  
  @return WriterFactory