/** * @throws RunTimeException when src is already added * @param string $name * @param string $action default append * @return ScriptTag */ public function addContent($name, $action = 'append') { if ($this->isAttribute('src')) { $err = 'can not add content to a script with a src attribute'; throw new RunTimeException($err); } return parent::addContent($name, $action); }
/** * Fix the tag to only be a body tag * * @param string $name * @return HeadTag */ public function setTagName($name) { if (!is_string($name) || 'body' !== strtolower($name)) { $err = 'this tag can only be a head tag'; throw new LogicException($err); } return parent::setTagName($name); }
/** * @param string $data content for the title * @return Title */ public function __construct($sep = null) { if (null === $sep) { $sep = PHP_EOL; } parent::__construct('head'); $this->setContentSeparator($sep)->setTitle(new TitleTag()); }
/** * Only has two valid attributes href and target * * @return base */ public function __construct(HeadTagInterface $head = null, GenericTagInterface $body = null) { $content = $this->createTagContent(null, PHP_EOL); $attrs = $this->createTagAttributes(array('manifest')); parent::__construct('html', $content, $attrs); if (null === $head) { $head = new HeadTag(); } $this->setHead($head); if (null === $body) { $body = new BodyTag(); } $this->setBody($body); }
/** * Only has two valid attributes href and target * * @return base */ public function __construct($href = null, $target = null) { parent::__construct('base'); $this->disableClosingTag(); $attrs = $this->getTagAttributes(); $attrs->loadWhiteList(array('href', 'target')); if (null === $href && null === $target) { $err = 'both params href and target can not be empty'; throw new RunTimeException($err); } if (is_string($href) && !empty($href)) { $attrs->add('href', $href); } if (is_string($target) && !empty($target)) { $attrs->add('target', $target); } }