From 713446093a839a5701b385b9f4727c3dc5c6d0a5 Mon Sep 17 00:00:00 2001 From: Joby Elliott Date: Sat, 9 Sep 2023 03:48:33 +0000 Subject: [PATCH] a bit more organization and cleanup --- .../DocumentTags/BodyTagInterface.php | 7 +- .../DocumentTags/TitleTagInterface.php | 9 +- src/ContentCategories/FlowContent.php | 7 - src/ContentCategories/HeadingContent.php | 7 - src/ContentCategories/MetadataContent.php | 7 - src/ContentCategories/PhrasingContent.php | 7 - src/ContentCategories/SectioningContent.php | 7 - src/ContentCategories/SectioningRoot.php | 7 - src/DisplayTypes/DisplayBlock.php | 7 - src/DisplayTypes/DisplayContents.php | 7 - src/DisplayTypes/DisplayInline.php | 7 - src/DisplayTypes/DisplayInlineBlock.php | 7 - src/DisplayTypes/DisplayNone.php | 7 - .../AbstractHeaderTag.php | 4 +- .../ContentSectioningTags/AddressTag.php | 4 +- .../ContentSectioningTags/ArticleTag.php | 5 +- src/Html5/ContentSectioningTags/AsideTag.php | 5 +- src/Html5/ContentSectioningTags/FooterTag.php | 4 +- src/Html5/ContentSectioningTags/HeaderTag.php | 4 +- src/Html5/ContentSectioningTags/MainTag.php | 4 +- src/Html5/ContentSectioningTags/NavTag.php | 5 +- src/Html5/ContentSectioningTags/SearchTag.php | 4 +- .../ContentSectioningTags/SectionTag.php | 5 +- src/Html5/Enums/ReferrerPolicy_a.php | 55 +++ src/Html5/Html5Parser.php | 1 + src/Html5/InlineTextSemantics/ATag.php | 326 ++++++++++++++++++ src/Html5/InlineTextSemantics/AbbrTag.php | 70 ++++ src/Html5/Tags/BaseTag.php | 3 +- src/Html5/Tags/HgroupTag.php | 4 +- src/Html5/Tags/LinkTag.php | 4 +- src/Html5/Tags/MetaTag.php | 3 +- src/Html5/Tags/NoscriptTag.php | 5 +- src/Html5/Tags/ScriptTag.php | 5 +- src/Html5/Tags/StyleTag.php | 3 +- src/Html5/TextContentTags/BlockquoteTag.php | 5 +- src/Html5/TextContentTags/DivTag.php | 4 +- src/Html5/TextContentTags/DlTag.php | 4 +- src/Html5/TextContentTags/FigcaptionTag.php | 4 +- src/Html5/TextContentTags/FigureTag.php | 4 +- src/Html5/TextContentTags/HrTag.php | 4 +- src/Html5/TextContentTags/LiTag.php | 4 +- src/Html5/TextContentTags/MenuTag.php | 4 +- src/Html5/TextContentTags/OlTag.php | 4 +- src/Html5/TextContentTags/PTag.php | 4 +- src/Html5/TextContentTags/PreTag.php | 3 +- src/Html5/TextContentTags/SpanTag.php | 5 +- src/Html5/TextContentTags/UlTag.php | 4 +- 47 files changed, 492 insertions(+), 177 deletions(-) delete mode 100644 src/ContentCategories/FlowContent.php delete mode 100644 src/ContentCategories/HeadingContent.php delete mode 100644 src/ContentCategories/MetadataContent.php delete mode 100644 src/ContentCategories/PhrasingContent.php delete mode 100644 src/ContentCategories/SectioningContent.php delete mode 100644 src/ContentCategories/SectioningRoot.php delete mode 100644 src/DisplayTypes/DisplayBlock.php delete mode 100644 src/DisplayTypes/DisplayContents.php delete mode 100644 src/DisplayTypes/DisplayInline.php delete mode 100644 src/DisplayTypes/DisplayInlineBlock.php delete mode 100644 src/DisplayTypes/DisplayNone.php create mode 100644 src/Html5/Enums/ReferrerPolicy_a.php create mode 100644 src/Html5/InlineTextSemantics/ATag.php create mode 100644 src/Html5/InlineTextSemantics/AbbrTag.php diff --git a/src/Containers/DocumentTags/BodyTagInterface.php b/src/Containers/DocumentTags/BodyTagInterface.php index aafe43a..f919d10 100644 --- a/src/Containers/DocumentTags/BodyTagInterface.php +++ b/src/Containers/DocumentTags/BodyTagInterface.php @@ -2,10 +2,9 @@ namespace ByJoby\HTML\Containers\DocumentTags; -use ByJoby\HTML\ContentCategories\FlowContent; -use ByJoby\HTML\ContentCategories\SectioningRoot; use ByJoby\HTML\Tags\ContainerTagInterface; +use ByJoby\HTML\Tags\TagInterface; -interface BodyTagInterface extends ContainerTagInterface, SectioningRoot, FlowContent +interface BodyTagInterface extends ContainerTagInterface, TagInterface { -} +} \ No newline at end of file diff --git a/src/Containers/DocumentTags/TitleTagInterface.php b/src/Containers/DocumentTags/TitleTagInterface.php index 115ec97..fa8046f 100644 --- a/src/Containers/DocumentTags/TitleTagInterface.php +++ b/src/Containers/DocumentTags/TitleTagInterface.php @@ -2,9 +2,10 @@ namespace ByJoby\HTML\Containers\DocumentTags; -use ByJoby\HTML\ContentCategories\MetadataContent; -use ByJoby\HTML\Tags\ContentTagInterface; +use Stringable; -interface TitleTagInterface extends ContentTagInterface, MetadataContent +interface TitleTagInterface { -} + public function setContent(string|Stringable $content): static; + public function content(): string|Stringable; +} \ No newline at end of file diff --git a/src/ContentCategories/FlowContent.php b/src/ContentCategories/FlowContent.php deleted file mode 100644 index 0316fa3..0000000 --- a/src/ContentCategories/FlowContent.php +++ /dev/null @@ -1,7 +0,0 @@ - */ protected $tag_namespaces = [ '\\ByJoby\\HTML\\Html5\\Tags\\', + '\\ByJoby\\HTML\\Html5\\InlineTextSemantics\\', '\\ByJoby\\HTML\\Html5\\TextContentTags\\', '\\ByJoby\\HTML\\Html5\\ContentSectioningTags\\', '\\ByJoby\\HTML\\Html5\\DocumentTags\\', diff --git a/src/Html5/InlineTextSemantics/ATag.php b/src/Html5/InlineTextSemantics/ATag.php new file mode 100644 index 0000000..1784825 --- /dev/null +++ b/src/Html5/InlineTextSemantics/ATag.php @@ -0,0 +1,326 @@ + HTML element (or anchor element), with its href attribute, creates a + * hyperlink to web pages, files, email addresses, locations in the same page, + * or anything else a URL can address. + * + * Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5 + * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a + */ +class ATag extends AbstractContainerTag +{ + const TAG = 'a'; + + /** + * Causes the browser to treat the linked URL as a download. Can be used + * with or without a filename value. + * + * @return null|string|Stringable|BooleanAttribute::true + */ + public function download(): null|string|Stringable|BooleanAttribute + { + if ($this->attributes()['download'] === BooleanAttribute::true) return BooleanAttribute::true; + else return $this->attributes()->asString('download'); + } + + /** + * Causes the browser to treat the linked URL as a download. Can be used + * with or without a filename value. + * + * @param null|string|Stringable|BooleanAttribute $download + * @return static + */ + public function setDownload(null|string|Stringable|BooleanAttribute $download): static + { + if ($download === BooleanAttribute::true) $this->attributes()['download'] = BooleanAttribute::true; + elseif ($download === BooleanAttribute::false) $this->unsetDownload(); + elseif ($download) $this->attributes()['download'] = $download; + else $this->unsetDownload(); + return $this; + } + + /** + * Causes the browser to treat the linked URL as a download. Can be used + * with or without a filename value. + * + * @return static + */ + public function unsetDownload(): static + { + unset($this->attributes()['download']); + return $this; + } + + /** + * The URL that the hyperlink points to. Links are not restricted to + * HTTP-based URLs — they can use any URL scheme supported by browsers + * + * @return null|string|Stringable + */ + public function href(): null|string|Stringable + { + return $this->attributes()->asString('href'); + } + + /** + * The URL that the hyperlink points to. Links are not restricted to + * HTTP-based URLs — they can use any URL scheme supported by browsers + * + * @param null|string|Stringable $href + * @return static + */ + public function setHref(null|string|Stringable $href): static + { + if ($href) $this->attributes()['href'] = $href; + else $this->unsetHref(); + return $this; + } + + /** + * The URL that the hyperlink points to. Links are not restricted to + * HTTP-based URLs — they can use any URL scheme supported by browsers + * + * @return static + */ + public function unsetHref(): static + { + $this->unsetHreflang(); + unset($this->attributes()['href']); + return $this; + } + + /** + * Hints at the human language of the linked URL. No built-in functionality. + * Allowed values are the same as the global lang attribute. + * + * @return null|string|Stringable + */ + public function hreflang(): null|string|Stringable + { + return $this->attributes()->asString('hreflang'); + } + + /** + * Hints at the human language of the linked URL. No built-in functionality. + * Allowed values are the same as the global lang attribute. + * + * @param null|string|Stringable $hreflang + * @return static + */ + public function setHreflang(null|string|Stringable $hreflang): static + { + if ($hreflang) $this->attributes()['hreflang'] = $hreflang; + else $this->unsetHreflang(); + return $this; + } + + /** + * Hints at the human language of the linked URL. No built-in functionality. + * Allowed values are the same as the global lang attribute. + * + * @return static + */ + public function unsetHreflang(): static + { + unset($this->attributes()['hreflang']); + return $this; + } + + /** + * A space-separated list of URLs. When the link is followed, the browser + * will send POST requests with the body PING to the URLs. Typically for + * tracking. + * + * @return null|string|Stringable + */ + public function ping(): null|string|Stringable + { + return $this->attributes()->asString('ping'); + } + + /** + * A space-separated list of URLs. When the link is followed, the browser + * will send POST requests with the body PING to the URLs. Typically for + * tracking. + * + * @param null|string|Stringable $ping + * @return static + */ + public function setPing(null|string|Stringable $ping): static + { + if ($ping) $this->attributes()['ping'] = $ping; + else $this->unsetPing(); + return $this; + } + + /** + * A space-separated list of URLs. When the link is followed, the browser + * will send POST requests with the body PING to the URLs. Typically for + * tracking. + * + * @return static + */ + public function unsetPing(): static + { + unset($this->attributes()['ping']); + return $this; + } + + /** + * An enum indicating which referrer to use when fetching the resource. + * + * @return null|ReferrerPolicy_a + */ + public function referrerpolicy(): null|ReferrerPolicy_a + { + return $this->attributes()->asEnum('referrerpolicy', ReferrerPolicy_a::class); + } + + /** + * An enum indicating which referrer to use when fetching the resource. + * + * @param null|ReferrerPolicy_a $referrerpolicy + * @return static + */ + public function setReferrerpolicy(null|ReferrerPolicy_a $referrerpolicy): static + { + if ($referrerpolicy) $this->attributes()['referrerpolicy'] = $referrerpolicy->value; + else $this->unsetReferrerpolicy(); + return $this; + } + + /** + * An enum indicating which referrer to use when fetching the resource. + * + * @return static + */ + public function unsetReferrerpolicy(): static + { + unset($this->attributes()['referrerpolicy']); + return $this; + } + + /** + * The relationship of the linked URL as space-separated link types. + * + * @return Rel_a[] + */ + public function rel(): array + { + return $this->attributes()->asEnumArray('rel', Rel_a::class, ' '); + } + + /** + * The relationship of the linked URL as space-separated link types. + * + * @param null|Rel_a|array $rel + * @return static + */ + public function setRel(null|Rel_a|array $rel): static + { + if ($rel) $this->attributes()->setEnumArray('rel', $rel, Rel_a::class, ' '); + else $this->unsetRel(); + return $this; + } + + /** + * The relationship of the linked URL as space-separated link types. + * + * @return static + */ + public function unsetRel(): static + { + unset($this->attributes()['rel']); + return $this; + } + + /** + * Where to display the linked URL, as the name for a browsing context (a + * tab, window, or