public function apply($transformer, $context_element, $node)
 {
     $h2 = H2::create();
     if (Type::is($context_element, array(Header::getClassName(), Caption::getClassName()))) {
         $context_element->withSubTitle($h2);
     } elseif (Type::is($context_element, InstantArticle::getClassName())) {
         $context_element->addChild($h2);
     }
     if ($this->getProperty(Caption::POSITION_BELOW, $node)) {
         $h2->withPosition(Caption::POSITION_BELOW);
     }
     if ($this->getProperty(Caption::POSITION_CENTER, $node)) {
         $h2->withPosition(Caption::POSITION_CENTER);
     }
     if ($this->getProperty(Caption::POSITION_ABOVE, $node)) {
         $h2->withPosition(Caption::POSITION_ABOVE);
     }
     if ($this->getProperty(Caption::ALIGN_LEFT, $node)) {
         $h2->withTextAlignment(Caption::ALIGN_LEFT);
     }
     if ($this->getProperty(Caption::ALIGN_CENTER, $node)) {
         $h2->withTextAlignment(Caption::ALIGN_CENTER);
     }
     if ($this->getProperty(Caption::ALIGN_RIGHT, $node)) {
         $h2->withTextAlignment(Caption::ALIGN_RIGHT);
     }
     $transformer->transform($h2, $node);
     return $context_element;
 }
 /**
  * The caption sub title. optional.
  *
  * @param string $sub_title the caption sub title text that will be shown
  *
  * @return $this
  */
 public function withSubTitle($sub_title)
 {
     Type::enforce($sub_title, [Type::STRING, H2::getClassName()]);
     if (Type::is($sub_title, Type::STRING)) {
         $sub_title = H2::create()->appendText($sub_title);
     }
     $this->subTitle = $sub_title;
     return $this;
 }
 /**
  * Sets the subtitle of InstantArticle
  *
  * @param string|H2 $subtitle The subtitle of the InstantArticle
  *
  * @return $this
  */
 public function withSubTitle($subtitle)
 {
     Type::enforce($subtitle, array(Type::STRING, H2::getClassName()));
     if (Type::is($subtitle, Type::STRING)) {
         $this->subtitle = H2::create()->appendText($subtitle);
     } else {
         $this->subtitle = $subtitle;
     }
     return $this;
 }
 public function apply($transformer, $header, $h2)
 {
     $header->withSubTitle($transformer->transform(H2::create(), $h2));
     return $header;
 }
 /**
  * Adds new child elements to the front of this InstantArticle
  *
  * @param Element to be added to this Article.
  *
  * @return $this
  */
 public function unshiftChild($child)
 {
     Type::enforce($child, [Ad::getClassName(), Analytics::getClassName(), AnimatedGIF::getClassName(), Audio::getClassName(), Blockquote::getClassName(), Image::getClassName(), H1::getClassName(), H2::getClassName(), Interactive::getClassName(), ListElement::getClassName(), Map::getClassName(), Paragraph::getClassName(), Pullquote::getClassName(), RelatedArticles::getClassName(), Slideshow::getClassName(), SocialEmbed::getClassName(), Video::getClassName()]);
     array_unshift($this->children, $child);
     return $this;
 }