tagHtml = new HtmlTag('html'); $this->tagHtml->appendChild($this->tagHead = new HtmlTag('head')); $this->tagHtml->appendChild($this->tagBody = new HtmlTag('body')); $this->tagHead->appendChild(new HtmlTag('meta', ['charset' => 'utf-8'], true)); $this->tagHead->appendChild(new HtmlTag('meta', ['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1'], true)); $this->tagHead->appendChild($this->tagTitle = new HtmlTag('title')); $this->tagHead->appendChild(new HtmlTag('link', ['href' => $sharedCss, 'type' => 'text/css', 'rel' => 'stylesheet'], true)); $this->tagHead->appendChild(new HtmlTag('script', ['charset' => 'utf-8', 'src' => $sharedJs])); $this->tagBody->appendChild($this->tagContainer = new HtmlTag('div', ['id' => 'container'])); $this->setTitle($pageTitle); } public function getHtml(): HtmlTag { return $this->tagHtml; } public function getHead(): HtmlTag { return $this->tagHead; } public function getBody(): HtmlTag { return $this->tagBody; } public function getContainer(): HtmlTag { return $this->tagContainer; } public function setTitle(string $title): void { $this->tagTitle->setTextContent($title); } public function getElementsByTagName(string $tagName): array { return $this->tagHtml->getElementsByTagName($tagName); } public function getElementsByClassName(string $className): array { return $this->tagHtml->getElementsByClassName($className); } public function getElementById(string $idString): ?HtmlTag { return $this->tagHtml->getElementById($idString); } public function serialise(): string { return '' . $this->tagHtml->asHTML(); } public function __toString(): string { return $this->serialise(); } }