code: public function getDocument($name = null)
      {
          if ($name) {
              if (!array_key_exists($name, $this->document)) {
                  throw new \InvalidArgumentException(sprintf(
                      'The document "%s" does not exist',
                      $name
                  ));
              }
  
              return $this->document[$name];
          } else {
              return $this->document;
          }
      }
docs: Get Document
  
  @param string|null $name name of document
  
  @return DocumentInterface or array