original_string: public function setLayout($layout, Document $document = NULL) {
      $class = 'ChapterThree\AppleNewsAPI\Document\Layouts\ComponentLayout';
      if (is_string($layout)) {
        // Check that layout exists.
        if ($document &&
            empty($document->getComponentLayouts()[$layout])
        ) {
          $this->triggerError("No component layout \"${layout}\" found.");
          return $this;
        }
      }
      elseif (!$layout instanceof $class) {
        $this->triggerError("Layout not of class ${class}.");
        return $this;
      }
      $this->layout = $layout;
      return $this;
    }
code: public function setLayout($layout, Document $document = NULL) {
      $class = 'ChapterThree\AppleNewsAPI\Document\Layouts\ComponentLayout';
      if (is_string($layout)) {
        // Check that layout exists.
        if ($document &&
            empty($document->getComponentLayouts()[$layout])
        ) {
          $this->triggerError("No component layout \"${layout}\" found.");
          return $this;
        }
      }
      elseif (!$layout instanceof $class) {
        $this->triggerError("Layout not of class ${class}.");
        return $this;
      }
      $this->layout = $layout;
      return $this;
    }
code_tokens: public function setLayout ( $ layout , Document $ document = NULL ) { $ class = 'ChapterThree\AppleNewsAPI\Document\Layouts\ComponentLayout' ; if ( is_string ( $ layout ) ) { // Check that layout exists. if ( $ document && empty ( $ document -> getComponentLayouts ( ) [ $ layout ] ) ) { $ this -> triggerError ( "No component layout \"${layout}\" found." ) ; return $ this ; } } elseif ( ! $ layout instanceof $ class ) { $ this -> triggerError ( "Layout not of class ${class}." ) ; return $ this ; } $ this -> layout = $ layout ; return $ this ; }
docstring: Setter for layout.
  
  @param \ChapterThree\AppleNewsAPI\Document\Layouts\ComponentLayout|string $layout
  Either a ComponentLayout object, or a string reference to one defined in
  $document.
  @param \ChapterThree\AppleNewsAPI\Document|NULL $document
  If required by first parameter.
  
  @return $this
docstring_tokens: Setter for layout .