Compare commits
41 commits
Author | SHA1 | Date | |
---|---|---|---|
|
7cab10643a | ||
880752b76f | |||
3aab0ee1c8 | |||
b6366b7972 | |||
07ed6e99d0 | |||
badca08266 | |||
990b6c1ea4 | |||
4bff7f2f87 | |||
8b70867e40 | |||
f03493c8ff | |||
632ca047b8 | |||
d093dce41a | |||
76a5eae11e | |||
7e87f6d618 | |||
1a12390c71 | |||
885975e3b4 | |||
713446093a | |||
f39dd9e1c2 | |||
e6941b3bd5 | |||
be264b0e5d | |||
a6096337b5 | |||
51de2d6f64 | |||
074b41167e | |||
74c8c7079f | |||
abea8a6f68 | |||
67763ada8f | |||
049d847fa9 | |||
44a06ef9fb | |||
bc5991fdaa | |||
82debbdb11 | |||
12afd5e0be | |||
0cecf9cc72 | |||
abaccd2fc7 | |||
1920ad571e | |||
7f42a0cfca | |||
56658e5a47 | |||
7298617363 | |||
b9f3e837f1 | |||
5898f89fb3 | |||
230f7fba77 | |||
0af465fe47 |
219 changed files with 15594 additions and 335 deletions
20
.github/workflows/ci.yml
vendored
Normal file
20
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
name: CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build-test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-versions: [8.1, 8.2, 8.3]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: php-actions/composer@v6
|
||||
- uses: php-actions/phpstan@v3
|
||||
- uses: php-actions/phpunit@v3
|
||||
with:
|
||||
version: 10
|
||||
test_suffix: "Test.php"
|
||||
php_version: ${{ matrix.php-versions }}
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
/vendor/
|
||||
composer.lock
|
||||
/vendor
|
||||
/composer.lock
|
||||
/.phpunit.result.cache
|
|
@ -1,9 +0,0 @@
|
|||
language: php
|
||||
php:
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4
|
||||
install:
|
||||
- composer install
|
||||
script: composer test
|
26
LICENSE
26
LICENSE
|
@ -1,21 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 Joby Elliott
|
||||
Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
Copyright (c) 2024 Joby Elliott
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# html-object-strings
|
||||
# Joby's HTML Object Strings
|
||||
|
||||
[![Build Status](https://travis-ci.org/jobyone/html-object-strings.svg?branch=main)](https://travis-ci.org/jobyone/html-object-strings)
|
||||
A library used for building and manipulating HTML tags, fragments, and documents through an object-oriented interface.
|
||||
|
||||
An HTML string-building library, used for building HTML strings from simple and easy-to-use objects.
|
||||
## Development status
|
||||
|
||||
**Super under development** do not use in production!
|
|
@ -1,34 +1,31 @@
|
|||
{
|
||||
"name": "byjoby/html-object-strings",
|
||||
"description": "Abstraction layer for constructing arbitrary HTML tags in PHP",
|
||||
"name": "joby/html-object-strings",
|
||||
"description": "Abstraction layer for constructing arbitrary HTML tags and documents in PHP",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [{
|
||||
"name": "Joby Elliott",
|
||||
"email": "joby@byjoby.com"
|
||||
}],
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"HtmlObjectStrings\\": "src/"
|
||||
"Joby\\HTML\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"HtmlObjectStrings\\": "tests/"
|
||||
"Joby\\HTML\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"phpunit"
|
||||
]
|
||||
"authors": [
|
||||
{
|
||||
"name": "Joby Elliott",
|
||||
"email": "code@byjoby.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "~8.1",
|
||||
"myclabs/deep-copy": "^1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7",
|
||||
"stevegrunwell/phpunit-markup-assertions": "^1.2"
|
||||
"phpunit/phpunit": "^10",
|
||||
"phpstan/phpstan": "^1",
|
||||
"mustangostang/spyc": "^0.6.3"
|
||||
}
|
||||
}
|
||||
|
|
4
phpstan.neon
Normal file
4
phpstan.neon
Normal file
|
@ -0,0 +1,4 @@
|
|||
parameters:
|
||||
level: 9
|
||||
paths:
|
||||
- src
|
|
@ -1,7 +1,10 @@
|
|||
<phpunit>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="All Tests">
|
||||
<testsuite name="PHPUnit">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
</phpunit>
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
/* HTML Object Strings | https://gitlab.com/byjoby/html-object-strings | MIT License */
|
||||
namespace HtmlObjectStrings;
|
||||
|
||||
class A extends GenericTag
|
||||
{
|
||||
const TAG = 'a';
|
||||
const SELFCLOSING = false;
|
||||
}
|
232
src/AbstractParser.php
Normal file
232
src/AbstractParser.php
Normal file
|
@ -0,0 +1,232 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML;
|
||||
|
||||
use Joby\HTML\Containers\Fragment;
|
||||
use Joby\HTML\Containers\FragmentInterface;
|
||||
use Joby\HTML\Containers\HtmlDocumentInterface;
|
||||
use Joby\HTML\Helpers\BooleanAttribute;
|
||||
use Joby\HTML\Nodes\CData;
|
||||
use Joby\HTML\Nodes\CDataInterface;
|
||||
use Joby\HTML\Nodes\Comment;
|
||||
use Joby\HTML\Nodes\CommentInterface;
|
||||
use Joby\HTML\Nodes\Text;
|
||||
use Joby\HTML\Nodes\TextInterface;
|
||||
use Joby\HTML\Tags\ContentTagInterface;
|
||||
use Joby\HTML\Tags\TagInterface;
|
||||
use DOMComment;
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
use DOMNode;
|
||||
use DOMText;
|
||||
|
||||
/**
|
||||
* Extensions of this class to create new parsers are primarily meant to be
|
||||
* controlled by adjusting the default properties below
|
||||
*/
|
||||
abstract class AbstractParser
|
||||
{
|
||||
/**
|
||||
* A list of namespaces in which to match tags. To match in this way the
|
||||
* tag classes must implement TagInterface and be named following the
|
||||
* convention of the tag name in CamelCase followed by "Tag" i.e. a class
|
||||
* implementing a tag <my-tag> would need to be named MyTagTag.
|
||||
*
|
||||
* They are searched in order and the first match is used.
|
||||
*
|
||||
* @var array<int,string>
|
||||
*/
|
||||
protected $tag_namespaces = [];
|
||||
|
||||
/**
|
||||
* A list of defined tag classes, matching a tag string (in lower case) to
|
||||
* a fully-qualified TagInterface-implementing class. This array is also
|
||||
* used at runtime to cache the pairings found and verified from
|
||||
* $tag_namespaces.
|
||||
*
|
||||
* They are searched in order and the first match is used.
|
||||
*
|
||||
* @var array<string,class-string<TagInterface>>
|
||||
*/
|
||||
protected $tag_classes = [];
|
||||
|
||||
/** @var class-string<CommentInterface> */
|
||||
protected $comment_class = Comment::class;
|
||||
|
||||
/** @var class-string<TextInterface> */
|
||||
protected $text_class = Text::class;
|
||||
|
||||
/** @var class-string<CDataInterface> */
|
||||
protected $cdata_class = CData::class;
|
||||
|
||||
/** @var class-string<HtmlDocumentInterface> */
|
||||
protected $document_class;
|
||||
|
||||
/** @var class-string<FragmentInterface> */
|
||||
protected $fragment_class = Fragment::class;
|
||||
|
||||
public function parseFragment(string $html): FragmentInterface
|
||||
{
|
||||
$fragment = new($this->fragment_class);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadHTML(
|
||||
'<div>' . $html . '</div>', // wrap in DIV otherwise it will wrap root-level text in P tags
|
||||
LIBXML_BIGLINES
|
||||
| LIBXML_COMPACT
|
||||
| LIBXML_HTML_NOIMPLIED
|
||||
| LIBXML_HTML_NODEFDTD
|
||||
| LIBXML_PARSEHUGE
|
||||
| LIBXML_NOERROR
|
||||
);
|
||||
// @phpstan-ignore-next-line we actually do know there's an item zero
|
||||
$this->walkDom($dom->childNodes->item(0), $fragment);
|
||||
return $fragment;
|
||||
}
|
||||
|
||||
public function parseDocument(string $html): HtmlDocumentInterface
|
||||
{
|
||||
/** @var HtmlDocumentInterface */
|
||||
$document = new($this->document_class);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadHTML(
|
||||
$html,
|
||||
LIBXML_BIGLINES
|
||||
| LIBXML_COMPACT
|
||||
| LIBXML_HTML_NODEFDTD
|
||||
| LIBXML_PARSEHUGE
|
||||
| LIBXML_NOERROR
|
||||
);
|
||||
$this->walkDom($dom, $document);
|
||||
return $document;
|
||||
}
|
||||
|
||||
protected function walkDom(DOMNode $node, ContainerInterface $parent): void
|
||||
{
|
||||
foreach ($node->childNodes as $child) {
|
||||
if ($converted_child = $this->convertNode($child)) {
|
||||
// append converted child to parent
|
||||
$parent->addChild($converted_child);
|
||||
// walk DOM for child if it is a container
|
||||
if ($converted_child instanceof ContainerInterface) {
|
||||
$this->walkDom($child, $converted_child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function convertNode(DOMNode $node): null|NodeInterface
|
||||
{
|
||||
if ($node instanceof DOMElement) {
|
||||
return $this->convertNodeToTag($node);
|
||||
} elseif ($node instanceof DOMComment) {
|
||||
return new($this->comment_class)($node->textContent);
|
||||
} elseif ($node instanceof DOMText) {
|
||||
$content = trim($node->textContent);
|
||||
if ($content) {
|
||||
return new($this->text_class)($content);
|
||||
}
|
||||
}
|
||||
// It's philosophically consistent to simply ignore unknown node types
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function convertNodeToTag(DOMElement $node): null|NodeInterface
|
||||
{
|
||||
// build object
|
||||
$class = $this->tagClass($node->tagName);
|
||||
if (!$class) {
|
||||
return null;
|
||||
}
|
||||
$tag = new $class();
|
||||
// tool for setting up content tags
|
||||
if ($tag instanceof ContentTagInterface) {
|
||||
$tag->setContent($node->textContent);
|
||||
}
|
||||
// external helper methods to stay tidy
|
||||
if ($tag instanceof TagInterface) {
|
||||
$this->processAttributes($node, $tag);
|
||||
}
|
||||
return $tag;
|
||||
}
|
||||
|
||||
protected function processAttributes(DOMElement $node, TagInterface $tag): void
|
||||
{
|
||||
$attributes = [];
|
||||
// absorb attributes from DOMNode
|
||||
/** @var DOMNode $attribute */
|
||||
foreach ($node->attributes ?? [] as $attribute) {
|
||||
if ($attribute->nodeValue) {
|
||||
$attributes[$attribute->nodeName] = $attribute->nodeValue;
|
||||
} else {
|
||||
$attributes[$attribute->nodeName] = BooleanAttribute::true;
|
||||
}
|
||||
}
|
||||
// set attributes internally
|
||||
foreach ($attributes as $k => $v) {
|
||||
if ($k == 'id' && is_string($v)) {
|
||||
$tag->setID($v);
|
||||
} elseif ($k == 'class' && is_string($v)) {
|
||||
$tag->classes()->parse($v);
|
||||
} elseif ($k == 'style' && is_string($v)) {
|
||||
$tag->styles()->parse($v);
|
||||
} else {
|
||||
// make an effort to set ID
|
||||
try {
|
||||
$tag->attributes()["$k"] = $v;
|
||||
} catch (\Throwable $th) { // @codeCoverageIgnore
|
||||
// does nothing
|
||||
// it is correct to ignore attributes that are unsettable
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tag
|
||||
* @return class-string<NodeInterface>|null
|
||||
*/
|
||||
protected function tagClass(string $tag): string|null
|
||||
{
|
||||
// look for an explicitly-set class
|
||||
if (isset($this->tag_classes[$tag])) {
|
||||
return $this->tag_classes[$tag];
|
||||
}
|
||||
// otherwise loop through namespaces and try to find a tag
|
||||
foreach ($this->tag_namespaces as $namespace) {
|
||||
$class = $namespace . ucfirst($tag) . 'Tag';
|
||||
if (class_exists($class)) {
|
||||
$implements = class_implements($class);
|
||||
$implements = $implements ? $implements : [];
|
||||
if (in_array(NodeInterface::class, $implements)) {
|
||||
$this->tag_classes[$tag] = $class; // @phpstan-ignore-line
|
||||
return $class; // @phpstan-ignore-line
|
||||
}
|
||||
}
|
||||
}
|
||||
// return null if nothing found
|
||||
return null;
|
||||
}
|
||||
}
|
60
src/ContainerInterface.php
Normal file
60
src/ContainerInterface.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML;
|
||||
|
||||
use Stringable;
|
||||
|
||||
interface ContainerInterface extends Stringable
|
||||
{
|
||||
/** @return array<int,NodeInterface> */
|
||||
public function children(): array;
|
||||
|
||||
public function contains(
|
||||
NodeInterface|Stringable|string $child
|
||||
): bool;
|
||||
|
||||
public function addChild(
|
||||
NodeInterface|Stringable|string $child,
|
||||
bool $prepend = false,
|
||||
bool $skip_sanitize = false
|
||||
): self;
|
||||
|
||||
public function removeChild(
|
||||
NodeInterface|Stringable|string $child
|
||||
): self;
|
||||
|
||||
public function addChildBefore(
|
||||
NodeInterface|Stringable|string $new_child,
|
||||
NodeInterface|Stringable|string $before_child,
|
||||
bool $skip_sanitize = false
|
||||
): self;
|
||||
|
||||
public function addChildAfter(
|
||||
NodeInterface|Stringable|string $new_child,
|
||||
NodeInterface|Stringable|string $after_child,
|
||||
bool $skip_sanitize = false
|
||||
): self;
|
||||
}
|
163
src/Containers/ContainerGroup.php
Normal file
163
src/Containers/ContainerGroup.php
Normal file
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers;
|
||||
|
||||
use Joby\HTML\ContainerInterface;
|
||||
use Joby\HTML\NodeInterface;
|
||||
use Joby\HTML\Tags\TagInterface;
|
||||
use Joby\HTML\Traits\ContainerTrait;
|
||||
use Joby\HTML\Traits\NodeTrait;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* @template T of NodeInterface
|
||||
* @method array<int,T> children()
|
||||
*/
|
||||
class ContainerGroup implements ContainerInterface, NodeInterface
|
||||
{
|
||||
use NodeTrait;
|
||||
use ContainerTrait {
|
||||
ContainerTrait::contains as doContains;
|
||||
ContainerTrait::addChild as doAddChild;
|
||||
ContainerTrait::addChildBefore as doAddChildBefore;
|
||||
ContainerTrait::addChildAfter as doAddChildAfter;
|
||||
}
|
||||
|
||||
/** @var callable */
|
||||
protected $validator;
|
||||
/** @var int */
|
||||
protected $limit = 0;
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ContainerGroup<NodeInterface>
|
||||
*/
|
||||
public static function catchAll(int $limit = 0): ContainerGroup
|
||||
{
|
||||
return new ContainerGroup(
|
||||
function () {
|
||||
return true;
|
||||
},
|
||||
$limit
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template C of T
|
||||
* @param class-string<C> $class
|
||||
* @param int $limit
|
||||
* @return ContainerGroup<C>
|
||||
*/
|
||||
public static function ofClass(string $class, int $limit = 0): ContainerGroup
|
||||
{
|
||||
return new ContainerGroup( // @phpstan-ignore-line
|
||||
function (NodeInterface $child) use ($class): bool {
|
||||
return $child instanceof $class;
|
||||
},
|
||||
$limit
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tag
|
||||
* @param int $limit
|
||||
* @return ContainerGroup<TagInterface>
|
||||
*/
|
||||
public static function ofTag(string $tag, int $limit = 0): ContainerGroup
|
||||
{
|
||||
return new ContainerGroup( // @phpstan-ignore-line
|
||||
function (NodeInterface $child) use ($tag): bool {
|
||||
if ($child instanceof TagInterface) {
|
||||
return $child->tag() == $tag;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
$limit
|
||||
);
|
||||
}
|
||||
|
||||
public function addChild(NodeInterface|Stringable|string $child, bool $prepend = false, bool $skip_sanitize = false): static
|
||||
{
|
||||
if ($this->willAccept($child)) {
|
||||
$this->doAddChild($child, $prepend, $skip_sanitize);
|
||||
$this->enforceChildLimit($prepend);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addChildAfter(NodeInterface|Stringable|string $new_child, NodeInterface|Stringable|string $after_child, bool $skip_sanitize = false): static
|
||||
{
|
||||
if ($this->willAccept($new_child)) {
|
||||
$this->doAddChildAfter($new_child, $after_child, $skip_sanitize);
|
||||
$this->enforceChildLimit(false);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addChildBefore(NodeInterface|Stringable|string $new_child, NodeInterface|Stringable|string $before_child, bool $skip_sanitize = false): static
|
||||
{
|
||||
if ($this->willAccept($new_child)) {
|
||||
$this->doAddChildBefore($new_child, $before_child, $skip_sanitize);
|
||||
$this->enforceChildLimit(true);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function enforceChildLimit(bool $remove_from_end): void
|
||||
{
|
||||
if ($this->limit > 0) {
|
||||
while (count($this->children) > $this->limit) {
|
||||
if ($remove_from_end) {
|
||||
$child = array_pop($this->children);
|
||||
} else {
|
||||
$child = array_shift($this->children);
|
||||
}
|
||||
$child->setParent(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function willAccept(NodeInterface|Stringable|string $child): bool
|
||||
{
|
||||
if ($child instanceof NodeInterface) {
|
||||
$child = $child->detachCopy();
|
||||
}
|
||||
$child = $this->prepareChildToAdd($child, false);
|
||||
return !!call_user_func($this->validator, $child);
|
||||
}
|
||||
|
||||
public function __construct(callable $validator, int $limit = 0)
|
||||
{
|
||||
$this->validator = $validator;
|
||||
$this->limit = $limit;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return implode(PHP_EOL, $this->children());
|
||||
}
|
||||
}
|
32
src/Containers/DocumentInterface.php
Normal file
32
src/Containers/DocumentInterface.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers;
|
||||
|
||||
use Joby\HTML\ContainerInterface;
|
||||
|
||||
interface DocumentInterface extends ContainerInterface
|
||||
{
|
||||
}
|
33
src/Containers/DocumentTags/BodyTagInterface.php
Normal file
33
src/Containers/DocumentTags/BodyTagInterface.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers\DocumentTags;
|
||||
|
||||
use Joby\HTML\Tags\ContainerTagInterface;
|
||||
use Joby\HTML\Tags\TagInterface;
|
||||
|
||||
interface BodyTagInterface extends ContainerTagInterface, TagInterface
|
||||
{
|
||||
}
|
32
src/Containers/DocumentTags/DoctypeInterface.php
Normal file
32
src/Containers/DocumentTags/DoctypeInterface.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers\DocumentTags;
|
||||
|
||||
use Joby\HTML\NodeInterface;
|
||||
|
||||
interface DoctypeInterface extends NodeInterface
|
||||
{
|
||||
}
|
33
src/Containers/DocumentTags/HeadTagInterface.php
Normal file
33
src/Containers/DocumentTags/HeadTagInterface.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers\DocumentTags;
|
||||
|
||||
use Joby\HTML\Tags\ContainerTagInterface;
|
||||
|
||||
interface HeadTagInterface extends ContainerTagInterface
|
||||
{
|
||||
public function title(): TitleTagInterface;
|
||||
}
|
35
src/Containers/DocumentTags/HtmlTagInterface.php
Normal file
35
src/Containers/DocumentTags/HtmlTagInterface.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers\DocumentTags;
|
||||
|
||||
use Joby\HTML\ContainerInterface;
|
||||
use Joby\HTML\Tags\TagInterface;
|
||||
|
||||
interface HtmlTagInterface extends ContainerInterface, TagInterface
|
||||
{
|
||||
public function head(): HeadTagInterface;
|
||||
public function body(): BodyTagInterface;
|
||||
}
|
32
src/Containers/DocumentTags/TitleTagInterface.php
Normal file
32
src/Containers/DocumentTags/TitleTagInterface.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers\DocumentTags;
|
||||
|
||||
use Joby\HTML\Tags\ContentTagInterface;
|
||||
|
||||
interface TitleTagInterface extends ContentTagInterface
|
||||
{
|
||||
}
|
54
src/Containers/Fragment.php
Normal file
54
src/Containers/Fragment.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers;
|
||||
|
||||
use Joby\HTML\NodeInterface;
|
||||
use Joby\HTML\Traits\ContainerTrait;
|
||||
use Stringable;
|
||||
use Traversable;
|
||||
|
||||
class Fragment implements FragmentInterface
|
||||
{
|
||||
use ContainerTrait;
|
||||
|
||||
/**
|
||||
* @param null|array<mixed,string|Stringable|NodeInterface>|Traversable<mixed,string|Stringable|NodeInterface>|null $children
|
||||
*/
|
||||
public function __construct(null|array|Traversable $children = null)
|
||||
{
|
||||
if (!$children) {
|
||||
return;
|
||||
}
|
||||
foreach ($children as $child) {
|
||||
$this->addChild($child);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return implode(PHP_EOL, $this->children());
|
||||
}
|
||||
}
|
32
src/Containers/FragmentInterface.php
Normal file
32
src/Containers/FragmentInterface.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers;
|
||||
|
||||
use Joby\HTML\ContainerInterface;
|
||||
|
||||
interface FragmentInterface extends DocumentInterface, ContainerInterface
|
||||
{
|
||||
}
|
50
src/Containers/GroupedContainer.php
Normal file
50
src/Containers/GroupedContainer.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers;
|
||||
|
||||
use Joby\HTML\ContainerInterface;
|
||||
use Joby\HTML\NodeInterface;
|
||||
use Joby\HTML\Traits\GroupedContainerTrait;
|
||||
use Joby\HTML\Traits\NodeTrait;
|
||||
|
||||
class GroupedContainer implements ContainerInterface, NodeInterface
|
||||
{
|
||||
use NodeTrait;
|
||||
use GroupedContainerTrait;
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return implode(
|
||||
PHP_EOL,
|
||||
array_filter(
|
||||
$this->groups(),
|
||||
function (ContainerGroup $group) {
|
||||
return !!$group->children();
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
39
src/Containers/HtmlDocumentInterface.php
Normal file
39
src/Containers/HtmlDocumentInterface.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Containers;
|
||||
|
||||
use Joby\HTML\Containers\DocumentTags\BodyTagInterface;
|
||||
use Joby\HTML\Containers\DocumentTags\DoctypeInterface;
|
||||
use Joby\HTML\Containers\DocumentTags\HeadTagInterface;
|
||||
use Joby\HTML\Containers\DocumentTags\HtmlTagInterface;
|
||||
|
||||
interface HtmlDocumentInterface extends DocumentInterface
|
||||
{
|
||||
public function doctype(): DoctypeInterface;
|
||||
public function html(): HtmlTagInterface;
|
||||
public function head(): HeadTagInterface;
|
||||
public function body(): BodyTagInterface;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
/* HTML Object Strings | https://gitlab.com/byjoby/html-object-strings | MIT License */
|
||||
namespace HtmlObjectStrings;
|
||||
|
||||
class GenericTag implements TagInterface
|
||||
{
|
||||
use TagTrait;
|
||||
|
||||
const TAG = 'span';
|
||||
const SELFCLOSING = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->htmlInit();
|
||||
}
|
||||
|
||||
protected function htmlInit()
|
||||
{
|
||||
$this->tag = static::TAG;
|
||||
$this->selfClosing = static::SELFCLOSING;
|
||||
}
|
||||
}
|
294
src/Helpers/Attributes.php
Normal file
294
src/Helpers/Attributes.php
Normal file
|
@ -0,0 +1,294 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Helpers;
|
||||
|
||||
use ArrayAccess;
|
||||
use ArrayIterator;
|
||||
use BackedEnum;
|
||||
use Joby\HTML\Helpers\BooleanAttribute;
|
||||
use Exception;
|
||||
use IteratorAggregate;
|
||||
use Stringable;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* Holds and validates a set of HTML attribute name/value pairs for use in tags.
|
||||
*
|
||||
* @implements ArrayAccess<string,string|number|Stringable|BooleanAttribute>
|
||||
* @implements IteratorAggregate<string,string|number|Stringable|BooleanAttribute>
|
||||
*/
|
||||
class Attributes implements IteratorAggregate, ArrayAccess
|
||||
{
|
||||
/** @var array<string,string|number|Stringable|BooleanAttribute> */
|
||||
protected $array = [];
|
||||
/** @var bool */
|
||||
protected $sorted = true;
|
||||
/** @var array<mixed,string> */
|
||||
protected $disallowed = [];
|
||||
|
||||
/**
|
||||
* @param null|array<string,string|number|Stringable|BooleanAttribute|BooleanAttribute> $array
|
||||
* @param array<mixed,string> $disallowed
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(null|array $array = null, $disallowed = [])
|
||||
{
|
||||
$this->disallowed = $disallowed;
|
||||
if (!$array) {
|
||||
return;
|
||||
}
|
||||
foreach ($array as $key => $value) {
|
||||
$this[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetExists(mixed $offset): bool
|
||||
{
|
||||
$offset = static::sanitizeOffset($offset);
|
||||
return isset($this->array[$offset]);
|
||||
}
|
||||
|
||||
public function offsetGet(mixed $offset): mixed
|
||||
{
|
||||
$offset = static::sanitizeOffset($offset);
|
||||
return @$this->array[$offset];
|
||||
}
|
||||
|
||||
public function offsetSet(mixed $offset, mixed $value): void
|
||||
{
|
||||
if (!$offset || !trim($offset)) {
|
||||
throw new Exception('Attribute name must be specified when setting');
|
||||
}
|
||||
$offset = static::sanitizeOffset($offset);
|
||||
if (in_array($offset, $this->disallowed)) {
|
||||
throw new Exception('Setting attribute is disallowed');
|
||||
}
|
||||
if (!isset($this->array[$offset])) {
|
||||
$this->sorted = false;
|
||||
}
|
||||
$this->array[$offset] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value as an array of enums, which will be internally saved as a
|
||||
* string separated by $separator. An array of Enum values can also be
|
||||
* retrieved using asEnumArray().
|
||||
*
|
||||
* @template T of BackedEnum
|
||||
* @param string $offset
|
||||
* @param null|BackedEnum|array<string|int,T> $value
|
||||
* @param class-string<T> $enum_class
|
||||
* @param string $separator
|
||||
* @return static
|
||||
*/
|
||||
public function setEnumArray(string $offset, null|BackedEnum|array $value, string $enum_class, string $separator): self
|
||||
{
|
||||
if (is_null($value)) {
|
||||
$value = [];
|
||||
}
|
||||
if ($value instanceof BackedEnum) {
|
||||
$value = [$value];
|
||||
}
|
||||
if (is_array($value)) {
|
||||
$value = new StringableEnumArray($value, ' ');
|
||||
}
|
||||
$this->offsetSet($offset, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a given offset's value as an array of enums. Note that this
|
||||
* method always returns an array, it will simply be empty for empty
|
||||
* attributes, unset attributes, or attributes with no valid values in them.
|
||||
*
|
||||
* @template T of BackedEnum
|
||||
* @param string $offset
|
||||
* @param class-string<T> $enum_class
|
||||
* @param non-empty-string $separator
|
||||
* @return array<string|int,T>
|
||||
*/
|
||||
public function asEnumArray(string $offset, string $enum_class, string $separator): array
|
||||
{
|
||||
$value = $this->offsetGet($offset);
|
||||
// short circuit if value is a boolean attribute
|
||||
if ($value instanceof BooleanAttribute) {
|
||||
return [];
|
||||
}
|
||||
// process as string
|
||||
$value = strval($value);
|
||||
$value = explode($separator, $value);
|
||||
if (!$enum_class::cases()) {
|
||||
// short-circuit if there are no cases in the enum
|
||||
return [];
|
||||
} elseif (is_string($enum_class::cases()[0]->value)) {
|
||||
// look at string values only
|
||||
$value = array_map(
|
||||
fn(string|int $e) => $enum_class::tryFrom(strval($e)),
|
||||
$value
|
||||
);
|
||||
} else {
|
||||
// look at int values only
|
||||
$value = array_map(
|
||||
fn(string|int $e) => $enum_class::tryFrom(intval($e)),
|
||||
$value
|
||||
);
|
||||
}
|
||||
// filter and return
|
||||
$value = array_filter(
|
||||
$value,
|
||||
fn($e) => !empty($e)
|
||||
);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a given offset's value as a string, if possible.
|
||||
*
|
||||
* @param string $offset
|
||||
* @return null|string|Stringable
|
||||
*/
|
||||
public function asString(string $offset): null|string|Stringable
|
||||
{
|
||||
$value = $this->offsetGet($offset);
|
||||
if (is_numeric($value)) {
|
||||
$value = strval($value);
|
||||
}
|
||||
if ($value instanceof Stringable || is_string($value)) {
|
||||
return $value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a given offset's value as an integer, if possible.
|
||||
*
|
||||
* @param string $offset
|
||||
* @return null|int
|
||||
*/
|
||||
public function asInt(string $offset): null|int
|
||||
{
|
||||
$value = $this->asNumber($offset);
|
||||
if (is_numeric($value)) {
|
||||
return intval($value);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a given offset's value as a float, if possible.
|
||||
*
|
||||
* @param string $offset
|
||||
* @return null|float
|
||||
*/
|
||||
public function asFloat(string $offset): null|float
|
||||
{
|
||||
$value = $this->asNumber($offset);
|
||||
if (!is_null($value)) {
|
||||
return floatval($value);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a given offset's value as a numeric type, if possible.
|
||||
*
|
||||
* @param string $offset
|
||||
* @return null|number
|
||||
*/
|
||||
public function asNumber(string $offset): null|int|float
|
||||
{
|
||||
$value = $this->offsetGet($offset);
|
||||
if (is_numeric($value)) {
|
||||
if (is_string($value)) {
|
||||
if ($value == intval($value)) {
|
||||
$value = intval($value);
|
||||
} else {
|
||||
$value = floatval($value);
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a given offset's value as an enum of the given class, if possible.
|
||||
*
|
||||
* @template T of BackedEnum
|
||||
* @param string $offset
|
||||
* @param class-string<T> $enum_class
|
||||
* @return null|T
|
||||
*/
|
||||
public function asEnum(string $offset, string $enum_class): null|BackedEnum
|
||||
{
|
||||
$value = $this->offsetGet($offset);
|
||||
if ($value instanceof Stringable) {
|
||||
$value = $value->__toString();
|
||||
}
|
||||
if (is_string($value) || is_int($value)) {
|
||||
return $enum_class::tryFrom($value);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetUnset(mixed $offset): void
|
||||
{
|
||||
$offset = static::sanitizeOffset($offset);
|
||||
unset($this->array[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string|number|Stringable|BooleanAttribute>
|
||||
*/
|
||||
public function getArray(): array
|
||||
{
|
||||
if (!$this->sorted) {
|
||||
ksort($this->array);
|
||||
$this->sorted = true;
|
||||
}
|
||||
return $this->array;
|
||||
}
|
||||
|
||||
public function getIterator(): Traversable
|
||||
{
|
||||
return new ArrayIterator($this->getArray());
|
||||
}
|
||||
|
||||
protected static function sanitizeOffset(string $offset): string
|
||||
{
|
||||
$offset = trim($offset);
|
||||
$offset = strtolower($offset);
|
||||
if (preg_match('/[\t\n\f \/>"\'=]/', $offset)) {
|
||||
throw new Exception('Invalid character in attribute name');
|
||||
}
|
||||
return $offset;
|
||||
}
|
||||
}
|
39
src/Helpers/BooleanAttribute.php
Normal file
39
src/Helpers/BooleanAttribute.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Helpers;
|
||||
|
||||
/**
|
||||
* This special enum is used to specify that an attribute is an HTML5 boolean
|
||||
* value. Any attribute set to BooleanAttribute::true will render as a lone tag,
|
||||
* with no value like <tag attribute>. Any attribute set to
|
||||
* BooleanAttribute::false will not render.
|
||||
*/
|
||||
enum BooleanAttribute {
|
||||
/** Render an attribute with no value */
|
||||
case true;
|
||||
/** Do not render this attribute */
|
||||
case false;
|
||||
}
|
127
src/Helpers/Classes.php
Normal file
127
src/Helpers/Classes.php
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Helpers;
|
||||
|
||||
use Countable;
|
||||
use Exception;
|
||||
use Stringable;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* Holds and sorts a list of CSS classes, including validation and add/remove/contains methods.
|
||||
*/
|
||||
class Classes implements Countable
|
||||
{
|
||||
/** @var array<int,string|Stringable> */
|
||||
protected $classes = [];
|
||||
/** @var bool */
|
||||
protected $sorted = true;
|
||||
|
||||
/**
|
||||
* @param null|array<mixed,string|Stringable>|Traversable<mixed,string|Stringable> $array
|
||||
*/
|
||||
public function __construct(null|array|Traversable $array = null, bool $no_exception = true)
|
||||
{
|
||||
if (!$array) {
|
||||
return;
|
||||
}
|
||||
foreach ($array as $class) {
|
||||
$this->add($class, $no_exception);
|
||||
}
|
||||
}
|
||||
|
||||
public function parse(string $class_string): void
|
||||
{
|
||||
foreach (explode(' ', $class_string) as $class) {
|
||||
$class = trim($class);
|
||||
if ($class) {
|
||||
$this->add($class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int,string|Stringable>
|
||||
*/
|
||||
public function getArray(): array
|
||||
{
|
||||
if (!$this->sorted) {
|
||||
sort($this->classes);
|
||||
$this->sorted = true;
|
||||
}
|
||||
return $this->classes;
|
||||
}
|
||||
|
||||
public function add(string|Stringable $class, bool $no_exception = false): self
|
||||
{
|
||||
try {
|
||||
$class = static::sanitizeClassName($class, true);
|
||||
} catch (\Throwable $th) {
|
||||
if ($no_exception) {
|
||||
return $this;
|
||||
} else {
|
||||
throw $th;
|
||||
}
|
||||
}
|
||||
if (!in_array($class, $this->classes)) {
|
||||
$this->classes[] = $class;
|
||||
$this->sorted = false;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function remove(string|Stringable $class): self
|
||||
{
|
||||
$class = static::sanitizeClassName($class);
|
||||
$this->classes = array_values(array_filter(
|
||||
$this->classes,
|
||||
function (string|Stringable $e) use ($class): bool {
|
||||
return $e != $class;
|
||||
}
|
||||
));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function contains(string|Stringable $class): bool
|
||||
{
|
||||
$class = static::sanitizeClassName($class);
|
||||
return in_array($class, $this->classes);
|
||||
}
|
||||
|
||||
protected static function sanitizeClassName(string $class, bool $validate = false): string
|
||||
{
|
||||
$class = trim($class);
|
||||
if ($validate && !preg_match('/^[_\-a-z][_\-a-z0-9]*$/i', $class)) {
|
||||
throw new Exception('Invalid class name');
|
||||
}
|
||||
return $class;
|
||||
}
|
||||
}
|
72
src/Helpers/StringableEnumArray.php
Normal file
72
src/Helpers/StringableEnumArray.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Helpers;
|
||||
|
||||
use ArrayIterator;
|
||||
use BackedEnum;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* @template T of BackedEnum
|
||||
* @extends ArrayIterator<int|string,T>
|
||||
*/
|
||||
class StringableEnumArray extends ArrayIterator implements Stringable
|
||||
{
|
||||
/**
|
||||
* @param array<int|string,T> $array
|
||||
*/
|
||||
public function __construct(
|
||||
$array = [],
|
||||
protected string $separator = ', '
|
||||
) {
|
||||
parent::__construct($array);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return implode(
|
||||
$this->separator,
|
||||
array_filter(
|
||||
$this->stringValues(),
|
||||
fn($e) => !empty($e)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int|string,string>
|
||||
*/
|
||||
protected function stringValues(): array
|
||||
{
|
||||
return array_map(
|
||||
function ($e) {
|
||||
if ($e instanceof BackedEnum) $e = $e->value;
|
||||
return strval($e);
|
||||
},
|
||||
$this->getArrayCopy()
|
||||
);
|
||||
}
|
||||
}
|
43
src/Helpers/StringableValue.php
Normal file
43
src/Helpers/StringableValue.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Helpers;
|
||||
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Class for automatically serializing and unserializing text values (such as in
|
||||
* attributes) between a text representation that can be rendered and an object
|
||||
* representation that is easy to work with.
|
||||
*
|
||||
* Objects that implement this can be passed into an Attributes object and will
|
||||
* be stored as their object form and automatically converted into strings at
|
||||
* render time. Some tags will have specific requirements for particular
|
||||
* implementations of this interface for particular attribute getters/setters.
|
||||
*/
|
||||
interface StringableValue extends Stringable
|
||||
{
|
||||
public static function fromString(string|Stringable|null $string): self|null;
|
||||
}
|
145
src/Helpers/Styles.php
Normal file
145
src/Helpers/Styles.php
Normal file
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Helpers;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use Stringable;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* A key difference in strategy between this class and Attributes or Classes is
|
||||
* that it does not make significant validation attempts. CSS is an evolving
|
||||
* language, and it would be a fool's errand to try and thoroughly validate it.
|
||||
*
|
||||
* To that end, this class is very accepting of not-obviously-malformed property
|
||||
* names and values.
|
||||
*
|
||||
* @implements ArrayAccess<string,null|string|Stringable>
|
||||
*/
|
||||
class Styles implements Countable, ArrayAccess, Stringable
|
||||
{
|
||||
/** @var array<string|string> */
|
||||
protected $styles = [];
|
||||
/** @var bool */
|
||||
protected $sorted = true;
|
||||
|
||||
/**
|
||||
* @param null|array<string,string|Stringable>|Traversable<string,string|Stringable>|null $classes
|
||||
*/
|
||||
public function __construct(null|array|Traversable $classes = null)
|
||||
{
|
||||
if (!$classes) {
|
||||
return;
|
||||
}
|
||||
foreach ($classes as $name => $value) {
|
||||
$this[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function parse(string $css_string): void
|
||||
{
|
||||
foreach (explode(';', $css_string) as $rule) {
|
||||
$rule = explode(':', trim($rule));
|
||||
if (count($rule) == 2) {
|
||||
$this[$rule[0]] = $rule[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->styles);
|
||||
}
|
||||
|
||||
public function offsetExists(mixed $offset): bool
|
||||
{
|
||||
return @isset($this->styles[$offset]);
|
||||
}
|
||||
|
||||
public function offsetGet(mixed $offset): mixed
|
||||
{
|
||||
return @$this->styles[$offset];
|
||||
}
|
||||
|
||||
public function offsetSet(mixed $offset, mixed $value): void
|
||||
{
|
||||
if (!$value) {
|
||||
unset($this->styles[$offset]);
|
||||
} else {
|
||||
if (!static::validate($offset, $value)) {
|
||||
return;
|
||||
}
|
||||
if (!isset($this->styles[$offset])) {
|
||||
$this->sorted = false;
|
||||
}
|
||||
$this->styles[$offset] = trim($value);
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetUnset(mixed $offset): void
|
||||
{
|
||||
unset($this->styles[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string>
|
||||
*/
|
||||
public function getArray(): array
|
||||
{
|
||||
if (!$this->sorted) {
|
||||
ksort($this->styles);
|
||||
$this->sorted = true;
|
||||
}
|
||||
return $this->styles;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$styles = [];
|
||||
foreach ($this->getArray() as $key => $value) {
|
||||
$styles[] = $key . ':' . $value;
|
||||
}
|
||||
return implode(';', $styles);
|
||||
}
|
||||
|
||||
protected static function validate(null|string $property, string $value): bool
|
||||
{
|
||||
if (!$property) {
|
||||
return false;
|
||||
} elseif (!preg_match('/[a-z]/', $property)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (str_contains($value, ';')) {
|
||||
return false;
|
||||
} elseif (str_contains($value, ':')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
32
src/Html5/ContentSectioningTags/AbstractHeaderTag.php
Normal file
32
src/Html5/ContentSectioningTags/AbstractHeaderTag.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
abstract class AbstractHeaderTag extends AbstractContainerTag
|
||||
{
|
||||
}
|
47
src/Html5/ContentSectioningTags/AddressTag.php
Normal file
47
src/Html5/ContentSectioningTags/AddressTag.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <address> HTML element indicates that the enclosed HTML provides contact
|
||||
* information for a person or people, or for an organization.
|
||||
*
|
||||
* The contact information provided by an <address> element's contents can take
|
||||
* whatever form is appropriate for the context, and may include any type of
|
||||
* contact information that is needed, such as a physical address, URL, email
|
||||
* address, phone number, social media handle, geographic coordinates, and so
|
||||
* forth. The <address> element should include the name of the person, people,
|
||||
* or organization to which the contact information refers.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/address
|
||||
*/
|
||||
class AddressTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'address';
|
||||
}
|
44
src/Html5/ContentSectioningTags/ArticleTag.php
Normal file
44
src/Html5/ContentSectioningTags/ArticleTag.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <article> HTML element represents a self-contained composition in a
|
||||
* document, page, application, or site, which is intended to be independently
|
||||
* distributable or reusable (e.g., in syndication). Examples include: a forum
|
||||
* post, a magazine or newspaper article, or a blog entry, a product card, a
|
||||
* user-submitted comment, an interactive widget or gadget, or any other
|
||||
* independent item of content.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article
|
||||
*/
|
||||
class ArticleTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'article';
|
||||
}
|
41
src/Html5/ContentSectioningTags/AsideTag.php
Normal file
41
src/Html5/ContentSectioningTags/AsideTag.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <aside> HTML element represents a portion of a document whose content is
|
||||
* only indirectly related to the document's main content. Asides are frequently
|
||||
* presented as sidebars or call-out boxes.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside
|
||||
*/
|
||||
class AsideTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'aside';
|
||||
}
|
42
src/Html5/ContentSectioningTags/FooterTag.php
Normal file
42
src/Html5/ContentSectioningTags/FooterTag.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <footer> HTML element represents a footer for its nearest ancestor
|
||||
* sectioning content or sectioning root element. A <footer> typically contains
|
||||
* information about the author of the section, copyright data or links to
|
||||
* related documents.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/footer
|
||||
*/
|
||||
class FooterTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'footer';
|
||||
}
|
40
src/Html5/ContentSectioningTags/H1Tag.php
Normal file
40
src/Html5/ContentSectioningTags/H1Tag.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
/**
|
||||
* The <h1> to <h6> HTML elements represent six levels of section headings. <h1>
|
||||
* is the highest section level and <h6> is the lowest. By default, all heading
|
||||
* elements create a block-level box in the layout, starting on a new line and
|
||||
* taking up the full width available in their containing block.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements
|
||||
*/
|
||||
class H1Tag extends AbstractHeaderTag
|
||||
{
|
||||
const TAG = 'h1';
|
||||
}
|
40
src/Html5/ContentSectioningTags/H2Tag.php
Normal file
40
src/Html5/ContentSectioningTags/H2Tag.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
/**
|
||||
* The <h1> to <h6> HTML elements represent six levels of section headings. <h1>
|
||||
* is the highest section level and <h6> is the lowest. By default, all heading
|
||||
* elements create a block-level box in the layout, starting on a new line and
|
||||
* taking up the full width available in their containing block.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements
|
||||
*/
|
||||
class H2Tag extends AbstractHeaderTag
|
||||
{
|
||||
const TAG = 'h1';
|
||||
}
|
40
src/Html5/ContentSectioningTags/H3Tag.php
Normal file
40
src/Html5/ContentSectioningTags/H3Tag.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
/**
|
||||
* The <h1> to <h6> HTML elements represent six levels of section headings. <h1>
|
||||
* is the highest section level and <h6> is the lowest. By default, all heading
|
||||
* elements create a block-level box in the layout, starting on a new line and
|
||||
* taking up the full width available in their containing block.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements
|
||||
*/
|
||||
class H3Tag extends AbstractHeaderTag
|
||||
{
|
||||
const TAG = 'h3';
|
||||
}
|
40
src/Html5/ContentSectioningTags/H4Tag.php
Normal file
40
src/Html5/ContentSectioningTags/H4Tag.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
/**
|
||||
* The <h1> to <h6> HTML elements represent six levels of section headings. <h1>
|
||||
* is the highest section level and <h6> is the lowest. By default, all heading
|
||||
* elements create a block-level box in the layout, starting on a new line and
|
||||
* taking up the full width available in their containing block.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements
|
||||
*/
|
||||
class H4Tag extends AbstractHeaderTag
|
||||
{
|
||||
const TAG = 'h4';
|
||||
}
|
40
src/Html5/ContentSectioningTags/H5Tag.php
Normal file
40
src/Html5/ContentSectioningTags/H5Tag.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
/**
|
||||
* The <h1> to <h6> HTML elements represent six levels of section headings. <h1>
|
||||
* is the highest section level and <h6> is the lowest. By default, all heading
|
||||
* elements create a block-level box in the layout, starting on a new line and
|
||||
* taking up the full width available in their containing block.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements
|
||||
*/
|
||||
class H5Tag extends AbstractHeaderTag
|
||||
{
|
||||
const TAG = 'h5';
|
||||
}
|
40
src/Html5/ContentSectioningTags/H6Tag.php
Normal file
40
src/Html5/ContentSectioningTags/H6Tag.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
/**
|
||||
* The <h1> to <h6> HTML elements represent six levels of section headings. <h1>
|
||||
* is the highest section level and <h6> is the lowest. By default, all heading
|
||||
* elements create a block-level box in the layout, starting on a new line and
|
||||
* taking up the full width available in their containing block.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements
|
||||
*/
|
||||
class H6Tag extends AbstractHeaderTag
|
||||
{
|
||||
const TAG = 'h6';
|
||||
}
|
41
src/Html5/ContentSectioningTags/HeaderTag.php
Normal file
41
src/Html5/ContentSectioningTags/HeaderTag.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <header> HTML element represents introductory content, typically a group
|
||||
* of introductory or navigational aids. It may contain some heading elements
|
||||
* but also a logo, a search form, an author name, and other elements.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/header
|
||||
*/
|
||||
class HeaderTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'header';
|
||||
}
|
42
src/Html5/ContentSectioningTags/MainTag.php
Normal file
42
src/Html5/ContentSectioningTags/MainTag.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <main> HTML element represents the dominant content of the <body> of a
|
||||
* document. The main content area consists of content that is directly related
|
||||
* to or expands upon the central topic of a document, or the central
|
||||
* functionality of an application.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/main
|
||||
*/
|
||||
class MainTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'main';
|
||||
}
|
42
src/Html5/ContentSectioningTags/NavTag.php
Normal file
42
src/Html5/ContentSectioningTags/NavTag.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <nav> HTML element represents a section of a page whose purpose is to
|
||||
* provide navigation links, either within the current document or to other
|
||||
* documents. Common examples of navigation sections are menus, tables of
|
||||
* contents, and indexes.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/nav
|
||||
*/
|
||||
class NavTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'nav';
|
||||
}
|
45
src/Html5/ContentSectioningTags/SearchTag.php
Normal file
45
src/Html5/ContentSectioningTags/SearchTag.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <search> HTML element is a container representing the parts of the
|
||||
* document or application with form controls or other content related to
|
||||
* performing a search or filtering operation. The <search> element semantically
|
||||
* identifies the purpose of the element's contents as having search or
|
||||
* filtering capabilities. The search or filtering functionality can be for the
|
||||
* website or application, the current web page or document, or the entire
|
||||
* Internet or subsection thereof.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/search
|
||||
*/
|
||||
class SearchTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'search';
|
||||
}
|
41
src/Html5/ContentSectioningTags/SectionTag.php
Normal file
41
src/Html5/ContentSectioningTags/SectionTag.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\ContentSectioningTags;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <section> HTML element represents a generic standalone section of a
|
||||
* document, which doesn't have a more specific semantic element to represent
|
||||
* it. Sections should always have a heading, with very few exceptions.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section
|
||||
*/
|
||||
class SectionTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'section';
|
||||
}
|
41
src/Html5/DocumentTags/BodyTag.php
Normal file
41
src/Html5/DocumentTags/BodyTag.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\DocumentTags;
|
||||
|
||||
use Joby\HTML\Containers\DocumentTags\BodyTagInterface;
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <body> HTML element represents the content of an HTML document. There can
|
||||
* be only one <body> element in a document.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
|
||||
*/
|
||||
class BodyTag extends AbstractContainerTag implements BodyTagInterface
|
||||
{
|
||||
const TAG = 'body';
|
||||
}
|
50
src/Html5/DocumentTags/Doctype.php
Normal file
50
src/Html5/DocumentTags/Doctype.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\DocumentTags;
|
||||
|
||||
use Joby\HTML\Containers\DocumentTags\DoctypeInterface;
|
||||
use Joby\HTML\Traits\NodeTrait;
|
||||
|
||||
/**
|
||||
* In HTML, the doctype is the required "<!DOCTYPE html>" preamble found at the
|
||||
* top of all documents. Its sole purpose is to prevent a browser from switching
|
||||
* into so-called "quirks mode" when rendering a document; that is, the
|
||||
* "<!DOCTYPE html>" doctype ensures that the browser makes a best-effort
|
||||
* attempt at following the relevant specifications, rather than using a
|
||||
* different rendering mode that is incompatible with some specifications.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Glossary/Doctype
|
||||
*/
|
||||
class Doctype implements DoctypeInterface
|
||||
{
|
||||
use NodeTrait;
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return '<!DOCTYPE html>';
|
||||
}
|
||||
}
|
69
src/Html5/DocumentTags/HeadTag.php
Normal file
69
src/Html5/DocumentTags/HeadTag.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\DocumentTags;
|
||||
|
||||
use Joby\HTML\Containers\ContainerGroup;
|
||||
use Joby\HTML\Containers\DocumentTags\HeadTagInterface;
|
||||
use Joby\HTML\Containers\DocumentTags\TitleTagInterface;
|
||||
use Joby\HTML\Tags\AbstractGroupedTag;
|
||||
use Joby\HTML\Traits\GroupedContainerTrait;
|
||||
|
||||
/**
|
||||
* The <head> HTML element contains machine-readable information (metadata)
|
||||
* about the document, like its title, scripts, and style sheets.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head
|
||||
*/
|
||||
class HeadTag extends AbstractGroupedTag implements HeadTagInterface
|
||||
{
|
||||
use GroupedContainerTrait;
|
||||
|
||||
const TAG = 'head';
|
||||
|
||||
/** @var ContainerGroup<TitleTagInterface> */
|
||||
protected $title;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->title = ContainerGroup::ofClass(TitleTagInterface::class, 1);
|
||||
$this->addGroup($this->title);
|
||||
$this->addChild(new TitleTag());
|
||||
$this->addGroup(ContainerGroup::ofTag('meta'));
|
||||
$this->addGroup(ContainerGroup::ofTag('base', 1));
|
||||
$this->addGroup(ContainerGroup::ofTag('style'));
|
||||
$this->addGroup(ContainerGroup::ofTag('script'));
|
||||
$this->addGroup(ContainerGroup::ofTag('noscript'));
|
||||
$this->addGroup(ContainerGroup::ofTag('template', 1));
|
||||
$this->addGroup(ContainerGroup::catchAll());
|
||||
}
|
||||
|
||||
public function title(): TitleTagInterface
|
||||
{
|
||||
return $this->title->children()[0];
|
||||
}
|
||||
}
|
74
src/Html5/DocumentTags/HtmlTag.php
Normal file
74
src/Html5/DocumentTags/HtmlTag.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\DocumentTags;
|
||||
|
||||
use Joby\HTML\Containers\ContainerGroup;
|
||||
use Joby\HTML\Containers\DocumentTags\BodyTagInterface;
|
||||
use Joby\HTML\Containers\DocumentTags\HeadTagInterface;
|
||||
use Joby\HTML\Containers\DocumentTags\HtmlTagInterface;
|
||||
use Joby\HTML\Tags\AbstractGroupedTag;
|
||||
use Joby\HTML\Traits\GroupedContainerTrait;
|
||||
|
||||
/**
|
||||
* The <html> HTML element represents the root (top-level element) of an HTML
|
||||
* document, so it is also referred to as the root element. All other elements
|
||||
* must be descendants of this element.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
|
||||
*/
|
||||
class HtmlTag extends AbstractGroupedTag implements HtmlTagInterface
|
||||
{
|
||||
use GroupedContainerTrait;
|
||||
|
||||
const TAG = 'html';
|
||||
|
||||
/** @var ContainerGroup<HeadTagInterface> */
|
||||
protected $head;
|
||||
/** @var ContainerGroup<BodyTagInterface> */
|
||||
protected $body;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->head = ContainerGroup::ofClass(HeadTagInterface::class, 1);
|
||||
$this->body = ContainerGroup::ofClass(BodyTagInterface::class, 1);
|
||||
$this->addGroup($this->head);
|
||||
$this->addGroup($this->body);
|
||||
$this->addChild(new HeadTag());
|
||||
$this->addChild(new BodyTag());
|
||||
}
|
||||
|
||||
public function head(): HeadTagInterface
|
||||
{
|
||||
return $this->head->children()[0];
|
||||
}
|
||||
|
||||
public function body(): BodyTagInterface
|
||||
{
|
||||
return $this->body->children()[0];
|
||||
}
|
||||
}
|
51
src/Html5/DocumentTags/TitleTag.php
Normal file
51
src/Html5/DocumentTags/TitleTag.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\DocumentTags;
|
||||
|
||||
use Joby\HTML\Containers\DocumentTags\TitleTagInterface;
|
||||
use Joby\HTML\Tags\AbstractContentTag;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* The <title> HTML element defines the document's title that is shown in a
|
||||
* browser's title bar or a page's tab. It only contains text; tags within the
|
||||
* element are ignored.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
|
||||
*/
|
||||
class TitleTag extends AbstractContentTag implements TitleTagInterface
|
||||
{
|
||||
const TAG = 'title';
|
||||
protected $content = 'Untitled';
|
||||
protected $inline = true;
|
||||
|
||||
public function setContent(string|Stringable $content): self
|
||||
{
|
||||
parent::setContent(trim(strip_tags($content)));
|
||||
return $this;
|
||||
}
|
||||
}
|
336
src/Html5/Enums/Autocomplete.php
Normal file
336
src/Html5/Enums/Autocomplete.php
Normal file
|
@ -0,0 +1,336 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Enums;
|
||||
|
||||
/**
|
||||
* The HTML autocomplete attribute lets web developers specify what if any
|
||||
* permission the user agent has to provide automated assistance in filling out
|
||||
* form field values, as well as guidance to the browser as to the type of
|
||||
* information expected in the field.
|
||||
*
|
||||
* It is available on <input> elements that take a text or numeric value as
|
||||
* input, <textarea> elements, <select> elements, and <form> elements.
|
||||
*
|
||||
* The source of the suggested values is generally up to the browser; typically
|
||||
* values come from past values entered by the user, but they may also come from
|
||||
* pre-configured values. For instance, a browser might let the user save their
|
||||
* name, address, phone number, and email addresses for autocomplete purposes.
|
||||
* Perhaps the browser offers the ability to save encrypted credit card
|
||||
* information, for autocompletion following an authentication procedure.
|
||||
*
|
||||
* If an <input>, <select> or <textarea> element has no autocomplete attribute,
|
||||
* then browsers use the autocomplete attribute of the element's form owner,
|
||||
* which is either the <form> element that the element is a descendant of, or
|
||||
* the <form> whose id is specified by the form attribute of the element (see
|
||||
* the <form> autocomplete attribute).
|
||||
*
|
||||
* Description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
|
||||
*/
|
||||
enum Autocomplete: string
|
||||
{
|
||||
/**
|
||||
* The browser is not permitted to automatically enter or select a value for
|
||||
* this field. It is possible that the document or application provides its
|
||||
* own autocomplete feature, or that security concerns require that the
|
||||
* field's value not be automatically entered.
|
||||
*/
|
||||
case off = "off";
|
||||
/**
|
||||
* The browser is allowed to automatically complete the input. No guidance
|
||||
* is provided as to the type of data expected in the field, so the browser
|
||||
* may use its own judgement.
|
||||
*/
|
||||
case on = "on";
|
||||
/**
|
||||
* The field expects the value to be a person's full name. Using "name"
|
||||
* rather than breaking the name down into its components is generally
|
||||
* preferred because it avoids dealing with the wide diversity of human
|
||||
* names and how they are structured; however, you can use a more specific
|
||||
* name_* value if you do need to break the name down into its components:
|
||||
*/
|
||||
case name = "name";
|
||||
/**
|
||||
* The prefix or title, such as "Mrs.", "Mr.", "Miss", "Ms.", "Dr.", or
|
||||
* "Mlle.".
|
||||
*/
|
||||
case name_honorific = "honorific-prefix";
|
||||
/**
|
||||
* The given (or "first") name.
|
||||
*/
|
||||
case name_first = "given-name";
|
||||
/**
|
||||
* The middle name.
|
||||
*/
|
||||
case name_middle = "additional-name";
|
||||
/**
|
||||
* The family (or "last") name.
|
||||
*/
|
||||
case name_last = "family-name";
|
||||
/**
|
||||
* The suffix, such as "Jr.", "B.Sc.", "PhD.", "MBASW", or "IV".
|
||||
*/
|
||||
case name_suffix = "honorific-suffix";
|
||||
/**
|
||||
* A nickname or handle.
|
||||
*/
|
||||
case nickname = "nickname";
|
||||
/**
|
||||
* An email address.
|
||||
*/
|
||||
case email = "email";
|
||||
/**
|
||||
* A username or account name.
|
||||
*/
|
||||
case username = "username";
|
||||
/**
|
||||
* The user's current password.
|
||||
*/
|
||||
case password = "current-password";
|
||||
/**
|
||||
* A new password. When creating a new account or changing passwords, this
|
||||
* should be used for an "Enter your new password" or "Confirm new password"
|
||||
* field, as opposed to a general "Enter your current password" field that
|
||||
* might be present. This may be used by the browser both to avoid
|
||||
* accidentally filling in an existing password and to offer assistance in
|
||||
* creating a secure password.
|
||||
*/
|
||||
case password_new = "new-password";
|
||||
/**
|
||||
* A one-time password (OTP) for verifying user information, most commonly a
|
||||
* phone number used as an additional factor in a sign-in flow.
|
||||
*/
|
||||
case otp = "one-time-code";
|
||||
/**
|
||||
* A job title, or the title a person has within an organization, such as
|
||||
* "Senior Technical Writer", "President", or "Assistant Troop Leader".
|
||||
*/
|
||||
case jobTitle = "organization-title";
|
||||
/**
|
||||
* A company or organization name, such as "Acme Widget Company" or "Girl
|
||||
* Scouts of America".
|
||||
*/
|
||||
case organization = "organization";
|
||||
/**
|
||||
* A street address. This can be multiple lines of text, and should fully
|
||||
* identify the location of the address within its second administrative
|
||||
* level (typically a city or town), but should not include the city name,
|
||||
* ZIP or postal code, or country name.
|
||||
*/
|
||||
case streetAddressCombined = "street-address";
|
||||
/**
|
||||
* The street address to send a product. This can be combined with other
|
||||
* tokens, such as "shipping street-address" and "shipping address-level2".
|
||||
*/
|
||||
case shipping = "shipping";
|
||||
/**
|
||||
* The street address to associate with the form of payment used. This can
|
||||
* be combined with other tokens, such as "billing street-address" and
|
||||
* "billing address-level2".
|
||||
*/
|
||||
case billing = "billing";
|
||||
/**
|
||||
* The first individual line of the street address. This should only be
|
||||
* present if the "street-address" is not present.
|
||||
*/
|
||||
case streetAddress1 = "address-line1";
|
||||
/**
|
||||
* The second individual line of the street address. This should only be
|
||||
* present if the "street-address" is not present.
|
||||
*/
|
||||
case streetAddress2 = "address-line2";
|
||||
/**
|
||||
* The third individual line of the street address. This should only be
|
||||
* present if the "street-address" is not present.
|
||||
*/
|
||||
case streetAddress3 = "address-line3";
|
||||
/**
|
||||
* The first administrative level in the address. This is typically the
|
||||
* province in which the address is located. In the United States, this
|
||||
* would be the state. In Switzerland, the canton. In the United Kingdom,
|
||||
* the post town.
|
||||
*/
|
||||
case addressLevel1 = "address-level1";
|
||||
/**
|
||||
* The second administrative level, in addresses with at least two of them.
|
||||
* In countries with two administrative levels, this would typically be the
|
||||
* city, town, village, or other locality in which the address is located.
|
||||
*/
|
||||
case addressLevel2 = "address-level2";
|
||||
/**
|
||||
* The third administrative level, in addresses with at least three
|
||||
* administrative levels.
|
||||
*/
|
||||
case addressLevel3 = "address-level3";
|
||||
/**
|
||||
* The fourth administrative level, in addresses with at least four
|
||||
* administrative levels.
|
||||
*/
|
||||
case addressLevel4 = "address-level4";
|
||||
/**
|
||||
* A country or territory code.
|
||||
*/
|
||||
case countryCode = "country";
|
||||
/**
|
||||
* A country or territory name.
|
||||
*/
|
||||
case country = "country-name";
|
||||
/**
|
||||
* A postal code (in the United States, this is the ZIP code).
|
||||
*/
|
||||
case postalCode = "postal-code";
|
||||
/**
|
||||
* The full name as printed on or associated with a payment instrument such
|
||||
* as a credit card. Using a full name field is preferred, typically, over
|
||||
* breaking the name into pieces.
|
||||
*/
|
||||
case creditCardName = "cc-name";
|
||||
/**
|
||||
* A given (first) name as given on a payment instrument like a credit card.
|
||||
*/
|
||||
case creditCardFirstName = "cc-given-name";
|
||||
/**
|
||||
* A middle name as given on a payment instrument or credit card.
|
||||
*/
|
||||
case creditCardMiddleName = "cc-additional-name";
|
||||
/**
|
||||
* A family name, as given on a credit card.
|
||||
*/
|
||||
case creditCardLastName = "cc-family-name";
|
||||
/**
|
||||
* A credit card number or other number identifying a payment method, such
|
||||
* as an account number.
|
||||
*/
|
||||
case paymentNumber = "cc-number";
|
||||
/**
|
||||
* A payment method expiration date, typically in the form "MM/YY" or "MM/YYYY".
|
||||
*/
|
||||
case creditCardExpiration = "cc-exp";
|
||||
/**
|
||||
* The year in which the payment method expires.
|
||||
*/
|
||||
case creditCardExpirationYear = "cc-exp-year";
|
||||
/**
|
||||
* The security code for the payment instrument; on credit cards, this is
|
||||
* the 3-digit verification number on the back of the card.
|
||||
*/
|
||||
case creditCardSecurityCode = "cc-csc";
|
||||
/**
|
||||
* The type of payment instrument (such as "Visa" or "Master Card").
|
||||
*/
|
||||
case creditCardType = "cc-type";
|
||||
/**
|
||||
* The currency in which the transaction is to take place.
|
||||
*/
|
||||
case transactionCurrency = "transaction-currency";
|
||||
/**
|
||||
* The amount, given in the currency specified by "transaction-currency", of
|
||||
* the transaction, for a payment form.
|
||||
*/
|
||||
case transactionAmount = "transaction-amount";
|
||||
/**
|
||||
* A preferred language, given as a valid BCP 47 language tag.
|
||||
* https://en.wikipedia.org/wiki/IETF_language_tag
|
||||
*/
|
||||
case language = "language";
|
||||
/**
|
||||
* A birth date, as a full date.
|
||||
*/
|
||||
case birthday = "bday";
|
||||
/**
|
||||
* The day of the month of a birth date.
|
||||
*/
|
||||
case birthdayDay = "bday-day";
|
||||
/**
|
||||
* The month of the year of a birth date.
|
||||
*/
|
||||
case birthdayMonth = "bday-month";
|
||||
/**
|
||||
* The year of a birth date.
|
||||
*/
|
||||
case birthdayYear = "bday-year";
|
||||
/**
|
||||
* A gender identity (such as "Female", "Fa'afafine", "Hijra", "Male",
|
||||
* "Nonbinary"), as freeform text without newlines.
|
||||
*/
|
||||
case gender = "sex";
|
||||
/**
|
||||
* A full telephone number, including the country code. If you need to break
|
||||
* the phone number up into its components, you can use more specific
|
||||
* phone_* values.
|
||||
*/
|
||||
case phone = "tel";
|
||||
/**
|
||||
* The entire phone number without the country code component, including a
|
||||
* country-internal prefix. For the phone number "1-855-555-6502", this
|
||||
* field's value would be "855-555-6502".
|
||||
*/
|
||||
case phone_national = "tel-national";
|
||||
/**
|
||||
* The phone number without the country or area code. This can be split
|
||||
* further into two parts, for phone numbers which have an exchange number
|
||||
* and then a number within the exchange. For the phone number "555-6502",
|
||||
* use "tel-local-prefix" for "555" and "tel-local-suffix" for "6502".
|
||||
*/
|
||||
case phone_local = "tel-local";
|
||||
/**
|
||||
* The country code, such as "1" for the United States, Canada, and other
|
||||
* areas in North America and parts of the Caribbean.
|
||||
*/
|
||||
case phone_country = "tel-country-code";
|
||||
/**
|
||||
* The area code, with any country-internal prefix applied if appropriate.
|
||||
*/
|
||||
case phone_area = "tel-area-code";
|
||||
/**
|
||||
* A telephone extension code within the phone number, such as a room or
|
||||
* suite number in a hotel or an office extension in a company.
|
||||
*/
|
||||
case phone_extension = "tel-extension";
|
||||
/**
|
||||
* A URL for an instant messaging protocol endpoint, such as
|
||||
* "xmpp:username@example.net".
|
||||
*/
|
||||
case impp = "impp";
|
||||
/**
|
||||
* A URL, such as a home page or company website address as appropriate
|
||||
* given the context of the other fields in the form.
|
||||
*/
|
||||
case url = "url";
|
||||
/**
|
||||
* The URL of an image representing the person, company, or contact
|
||||
* information given in the other fields in the form.
|
||||
*/
|
||||
case photo = "photo";
|
||||
/**
|
||||
* Passkeys generated by the Web Authentication API, as requested by a
|
||||
* conditional navigator.credentials.get() call (i.e., one that includes
|
||||
* mediation: 'conditional'). See Sign in with a passkey through form
|
||||
* autofill for more details.
|
||||
* https://web.dev/passkey-form-autofill/
|
||||
*/
|
||||
case webauthn = "webauthn";
|
||||
}
|
57
src/Html5/Enums/BrowsingContext.php
Normal file
57
src/Html5/Enums/BrowsingContext.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Enums;
|
||||
|
||||
/**
|
||||
* A browsing context is an environment in which a browser displays a Document.
|
||||
* In modern browsers, it usually is a tab, but can be a window or even only
|
||||
* parts of a page, like a frame or an iframe.
|
||||
*
|
||||
* Descriptions by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Glossary/Browsing_context
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
|
||||
*/
|
||||
enum BrowsingContext: string {
|
||||
/**
|
||||
* the current browsing context. (Default)
|
||||
*/
|
||||
case current = "_self";
|
||||
/**
|
||||
* usually a new tab, but users can configure browsers to open a new window
|
||||
* instead.
|
||||
*/
|
||||
case blank = "_blank";
|
||||
/**
|
||||
* the parent browsing context of the current one. If no parent, behaves as
|
||||
* _self.
|
||||
*/
|
||||
case parent = "_parent";
|
||||
/**
|
||||
* the topmost browsing context (the "highest" context that's an ancestor of
|
||||
* the current one). If no ancestors, behaves as _self.
|
||||
*/
|
||||
case top = "_top";
|
||||
}
|
52
src/Html5/Enums/Capture.php
Normal file
52
src/Html5/Enums/Capture.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Enums;
|
||||
|
||||
/**
|
||||
* The capture attribute specifies that, optionally, a new file should be
|
||||
* captured, and which device should be used to capture that new media of a type
|
||||
* defined by the accept attribute.
|
||||
*
|
||||
* Values include user and environment. The capture attribute is supported on
|
||||
* the file input type.
|
||||
*
|
||||
* The capture attribute takes as its value a string that specifies which camera
|
||||
* to use for capture of image or video data, if the accept attribute indicates
|
||||
* that the input should be of one of those types.
|
||||
*
|
||||
* Description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture
|
||||
*/
|
||||
enum Autocomplete: string {
|
||||
/**
|
||||
* The user-facing camera and/or microphone should be used.
|
||||
*/
|
||||
case user = "user";
|
||||
/**
|
||||
* The outward-facing camera and/or microphone should be used
|
||||
*/
|
||||
case environment = "environment";
|
||||
}
|
32
src/Html5/Enums/Draggable.php
Normal file
32
src/Html5/Enums/Draggable.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Enums;
|
||||
|
||||
enum Draggable: string
|
||||
{
|
||||
case true = "true";
|
||||
case false = "false";
|
||||
}
|
84
src/Html5/Enums/InputMode.php
Normal file
84
src/Html5/Enums/InputMode.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Enums;
|
||||
|
||||
/**
|
||||
* The inputmode global attribute is an enumerated attribute that hints at the
|
||||
* type of data that might be entered by the user while editing the element or
|
||||
* its contents. This allows a browser to display an appropriate virtual
|
||||
* keyboard.
|
||||
*
|
||||
* It is used primarily on <input> elements, but is usable on any element in
|
||||
* contenteditable mode.
|
||||
*
|
||||
* Description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode
|
||||
*/
|
||||
enum InputMode: string
|
||||
{
|
||||
/**
|
||||
* No virtual keyboard. For when the page implements its own keyboard input
|
||||
* control.
|
||||
*/
|
||||
case none = "none";
|
||||
/**
|
||||
* Standard input keyboard for the user's current locale.
|
||||
*/
|
||||
case text = "text";
|
||||
/**
|
||||
* Fractional numeric input keyboard containing the digits and decimal
|
||||
* separator for the user's locale (typically . or ,). Devices may or may
|
||||
* not show a minus key (-).
|
||||
*/
|
||||
case numeric = "numeric";
|
||||
/**
|
||||
* A telephone keypad input, including the digits 0–9, the asterisk (*), and
|
||||
* the pound (#) key. Inputs that *require* a telephone number should
|
||||
* typically use <input type="tel"> instead.
|
||||
*/
|
||||
case phone = "tel";
|
||||
/**
|
||||
* A virtual keyboard optimized for search input. For instance, the
|
||||
* return/submit key may be labeled "Search", along with possible other
|
||||
* optimizations. Inputs that require a search query should typically use
|
||||
* <input type="search"> instead.
|
||||
*/
|
||||
case search = "search";
|
||||
/**
|
||||
* A virtual keyboard optimized for entering email addresses. Typically
|
||||
* includes the @character as well as other optimizations. Inputs that
|
||||
* require email addresses should typically use <input type="email">
|
||||
* instead.
|
||||
*/
|
||||
case email = "email";
|
||||
/**
|
||||
* A keypad optimized for entering URLs. This may have the / key more
|
||||
* prominent, for example. Enhanced features could include history access
|
||||
* and so on. Inputs that require a URL should typically use <input
|
||||
* type="url"> instead.
|
||||
*/
|
||||
case url = "url";
|
||||
}
|
34
src/Html5/Enums/ListTypeValue.php
Normal file
34
src/Html5/Enums/ListTypeValue.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Enums;
|
||||
|
||||
enum ListTypeValue: string {
|
||||
case letterLower = 'a';
|
||||
case letterUpper = 'A';
|
||||
case romanLower = 'i';
|
||||
case romanUpper = 'I';
|
||||
case number = '1';
|
||||
}
|
88
src/Html5/Enums/Rel_form.php
Normal file
88
src/Html5/Enums/Rel_form.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Enums;
|
||||
|
||||
/**
|
||||
* The rel attribute defines the relationship between a linked resource and the
|
||||
* current document. These values are valid in <form> elements.
|
||||
*
|
||||
* Description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel
|
||||
*/
|
||||
enum Rel_form: string
|
||||
{
|
||||
/**
|
||||
* The referenced document is not part of the same site as the current
|
||||
* document.
|
||||
*/
|
||||
case external = "external";
|
||||
/**
|
||||
* Link to context-sensitive help.
|
||||
*/
|
||||
case help = "help";
|
||||
/**
|
||||
* Indicates that the main content of the current document is covered by the
|
||||
* copyright license. described by the referenced document.
|
||||
*/
|
||||
case license = "license";
|
||||
/**
|
||||
* Indicates that the current document is a part of a series and that the
|
||||
* next document in the series is the referenced document.
|
||||
*/
|
||||
case next = "next";
|
||||
/**
|
||||
* Indicates that the current document's original author or publisher does
|
||||
* not endorse the referenced document.
|
||||
*/
|
||||
case noFollow = "nofollow";
|
||||
/**
|
||||
* Creates a top-level browsing context that is not an auxiliary browsing
|
||||
* context if the hyperlink would create either of those, to begin with
|
||||
* (i.e., has an appropriate target attribute value).
|
||||
*/
|
||||
case noOpener = "noopener";
|
||||
/**
|
||||
* No Referer header will be included. Additionally, has the same effect as
|
||||
* noopener.
|
||||
*/
|
||||
case noReferrer = "noreferrer";
|
||||
/**
|
||||
* Creates an auxiliary browsing context if the hyperlink would otherwise
|
||||
* create a top-level browsing context that is not an auxiliary browsing
|
||||
* context (i.e., has "_blank" as target attribute value).
|
||||
*/
|
||||
case opener = "opener";
|
||||
/**
|
||||
* Indicates that the current document is a part of a series and that the
|
||||
* previous document in the series is the referenced document.
|
||||
*/
|
||||
case previous = "prev";
|
||||
/**
|
||||
* Gives a link to a resource that can be used to search through the current
|
||||
* document and its related pages.
|
||||
*/
|
||||
case search = "search";
|
||||
}
|
32
src/Html5/Enums/SpellcheckValue.php
Normal file
32
src/Html5/Enums/SpellcheckValue.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Enums;
|
||||
|
||||
enum SpellcheckValue: string
|
||||
{
|
||||
case true = "true";
|
||||
case false = "false";
|
||||
}
|
41
src/Html5/Enums/TranslateValue.php
Normal file
41
src/Html5/Enums/TranslateValue.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Enums;
|
||||
|
||||
/**
|
||||
* The translate global attribute is an enumerated attribute that is used to
|
||||
* specify whether an element's translatable attribute values and its Text node
|
||||
* children should be translated when the page is localized, or whether to leave
|
||||
* them unchanged.
|
||||
*
|
||||
* Description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/translate
|
||||
*/
|
||||
enum TranslateValue: string
|
||||
{
|
||||
case true = "yes";
|
||||
case false = "no";
|
||||
}
|
32
src/Html5/Exceptions/InvalidArgumentsException.php
Normal file
32
src/Html5/Exceptions/InvalidArgumentsException.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InvalidArgumentsException extends Exception
|
||||
{
|
||||
}
|
32
src/Html5/Exceptions/InvalidStateException.php
Normal file
32
src/Html5/Exceptions/InvalidStateException.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InvalidStateException extends Exception
|
||||
{
|
||||
}
|
89
src/Html5/Html5Document.php
Normal file
89
src/Html5/Html5Document.php
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5;
|
||||
|
||||
use Joby\HTML\Containers\ContainerGroup;
|
||||
use Joby\HTML\Containers\DocumentTags\BodyTagInterface;
|
||||
use Joby\HTML\Containers\DocumentTags\DoctypeInterface;
|
||||
use Joby\HTML\Containers\DocumentTags\HeadTagInterface;
|
||||
use Joby\HTML\Containers\DocumentTags\HtmlTagInterface;
|
||||
use Joby\HTML\Containers\HtmlDocumentInterface;
|
||||
use Joby\HTML\Html5\DocumentTags\Doctype;
|
||||
use Joby\HTML\Html5\DocumentTags\HtmlTag;
|
||||
use Joby\HTML\Traits\GroupedContainerTrait;
|
||||
|
||||
class Html5Document implements HtmlDocumentInterface
|
||||
{
|
||||
use GroupedContainerTrait;
|
||||
|
||||
/** @var ContainerGroup<DoctypeInterface> */
|
||||
protected $doctype;
|
||||
/** @var ContainerGroup<HtmlTagInterface> */
|
||||
protected $html;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->doctype = ContainerGroup::ofClass(DoctypeInterface::class, 1);
|
||||
$this->html = ContainerGroup::ofClass(HtmlTagInterface::class, 1);
|
||||
$this->addGroup($this->doctype);
|
||||
$this->addGroup($this->html);
|
||||
$this->addChild(new Doctype());
|
||||
$this->addChild(new HtmlTag());
|
||||
}
|
||||
|
||||
public function doctype(): DoctypeInterface
|
||||
{
|
||||
return $this->doctype->children()[0];
|
||||
}
|
||||
|
||||
public function html(): HtmlTagInterface
|
||||
{
|
||||
return $this->html->children()[0];
|
||||
}
|
||||
|
||||
public function head(): HeadTagInterface
|
||||
{
|
||||
return $this->html()->head();
|
||||
}
|
||||
|
||||
public function body(): BodyTagInterface
|
||||
{
|
||||
return $this->html()->body();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return implode(
|
||||
PHP_EOL,
|
||||
array_filter(
|
||||
$this->groups(),
|
||||
function (ContainerGroup $group) {
|
||||
return !!$group->children();
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
48
src/Html5/Html5Parser.php
Normal file
48
src/Html5/Html5Parser.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5;
|
||||
|
||||
use Joby\HTML\AbstractParser;
|
||||
use Joby\HTML\Containers\HtmlDocumentInterface;
|
||||
|
||||
/**
|
||||
* A Parser configured to parse and render HTML5.
|
||||
*/
|
||||
class Html5Parser extends AbstractParser
|
||||
{
|
||||
/** @var array<int,string> */
|
||||
protected $tag_namespaces = [
|
||||
'\\Joby\\HTML\\Html5\\ContentSectioningTags\\',
|
||||
'\\Joby\\HTML\\Html5\\DocumentTags\\',
|
||||
'\\Joby\\HTML\\Html5\\InlineTextSemantics\\',
|
||||
'\\Joby\\HTML\\Html5\\Multimedia\\',
|
||||
'\\Joby\\HTML\\Html5\\Tags\\',
|
||||
'\\Joby\\HTML\\Html5\\TextContentTags\\',
|
||||
];
|
||||
|
||||
/** @var class-string<HtmlDocumentInterface> */
|
||||
protected $document_class = Html5Document::class;
|
||||
}
|
43
src/Html5/InlineTextSemantics/ATag.php
Normal file
43
src/Html5/InlineTextSemantics/ATag.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Html5\Traits\HyperlinkTrait;
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <a> 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
|
||||
{
|
||||
use HyperlinkTrait;
|
||||
const TAG = 'a';
|
||||
}
|
93
src/Html5/InlineTextSemantics/AbbrTag.php
Normal file
93
src/Html5/InlineTextSemantics/AbbrTag.php
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* The <abbr> HTML element represents an abbreviation or acronym.
|
||||
*
|
||||
* When including an abbreviation or acronym, provide a full expansion of the
|
||||
* term in plain text on first use, along with the <abbr> to mark up the
|
||||
* abbreviation. This informs the user what the abbreviation or acronym means.
|
||||
*
|
||||
* The optional title attribute can provide an expansion for the abbreviation or
|
||||
* acronym when a full expansion is not present. This provides a hint to user
|
||||
* agents on how to announce/display the content while informing all users what
|
||||
* the abbreviation means. If present, title must contain this full description
|
||||
* and nothing else.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/abbr
|
||||
*/
|
||||
class AbbrTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'abbr';
|
||||
|
||||
/**
|
||||
* The title attribute has a specific semantic meaning when used with the
|
||||
* <abbr> element; it must contain a full human-readable description or
|
||||
* expansion of the abbreviation. This text is often presented by browsers
|
||||
* as a tooltip when the mouse cursor is hovered over the element.
|
||||
*
|
||||
* @return null|string|Stringable
|
||||
*/
|
||||
public function title(): null|string|Stringable
|
||||
{
|
||||
return $this->attributes()->asString('title');
|
||||
}
|
||||
|
||||
/**
|
||||
* The title attribute has a specific semantic meaning when used with the
|
||||
* <abbr> element; it must contain a full human-readable description or
|
||||
* expansion of the abbreviation. This text is often presented by browsers
|
||||
* as a tooltip when the mouse cursor is hovered over the element.
|
||||
*
|
||||
* @param null|string|Stringable $title
|
||||
* @return static
|
||||
*/
|
||||
public function setTitle(null|string|Stringable $title): self
|
||||
{
|
||||
if ($title) $this->attributes()['title'] = $title;
|
||||
else $this->unsetTitle();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The title attribute has a specific semantic meaning when used with the
|
||||
* <abbr> element; it must contain a full human-readable description or
|
||||
* expansion of the abbreviation. This text is often presented by browsers
|
||||
* as a tooltip when the mouse cursor is hovered over the element.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function unsetTitle(): self
|
||||
{
|
||||
unset($this->attributes()['title']);
|
||||
return $this;
|
||||
}
|
||||
}
|
57
src/Html5/InlineTextSemantics/BTag.php
Normal file
57
src/Html5/InlineTextSemantics/BTag.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <b> HTML element is used to draw the reader's attention to the element's
|
||||
* contents, which are not otherwise granted special importance. This was
|
||||
* formerly known as the Boldface element, and most browsers still draw the text
|
||||
* in boldface. However, you should not use <b> for styling text or granting
|
||||
* importance. If you wish to create boldface text, you should use the CSS
|
||||
* font-weight property. If you wish to indicate an element is of special
|
||||
* importance, you should use the <strong> element.
|
||||
*
|
||||
* Do not confuse the <b> element with the <strong>, <em>, or <mark> elements.
|
||||
* The <strong> element represents text of certain importance, <em> puts some
|
||||
* emphasis on the text and the <mark> element represents text of certain
|
||||
* relevance. The <b> element doesn't convey such special semantic information;
|
||||
* use it only when no others fit.
|
||||
*
|
||||
* It is a good practice to use the class attribute on the <b> element in order
|
||||
* to convey additional semantic information as needed (for example <b
|
||||
* class="lead"> for the first sentence in a paragraph). This makes it easier to
|
||||
* manage multiple use cases of <b> if your stylistic needs change, without the
|
||||
* need to change all of its uses in the HTML.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b
|
||||
*/
|
||||
class BTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'b';
|
||||
}
|
52
src/Html5/InlineTextSemantics/BdiTag.php
Normal file
52
src/Html5/InlineTextSemantics/BdiTag.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <bdi> HTML element tells the browser's bidirectional algorithm to treat
|
||||
* the text it contains in isolation from its surrounding text. It's
|
||||
* particularly useful when a website dynamically inserts some text and doesn't
|
||||
* know the directionality of the text being inserted.
|
||||
*
|
||||
* Bidirectional text is text that may contain both sequences of characters that
|
||||
* are arranged left-to-right (LTR) and sequences of characters that are
|
||||
* arranged right-to-left (RTL), such as an Arabic quotation embedded in an
|
||||
* English string. Browsers implement the Unicode Bidirectional Algorithm to
|
||||
* handle this. In this algorithm, characters are given an implicit
|
||||
* directionality: for example, Latin characters are treated as LTR while Arabic
|
||||
* characters are treated as RTL. Some other characters (such as spaces and some
|
||||
* punctuation) are treated as neutral and are assigned directionality based on
|
||||
* that of their surrounding characters.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/bdi
|
||||
*/
|
||||
class BdiTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'bdi';
|
||||
}
|
40
src/Html5/InlineTextSemantics/BdoTag.php
Normal file
40
src/Html5/InlineTextSemantics/BdoTag.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <bdo> HTML element overrides the current directionality of text, so that
|
||||
* the text within is rendered in a different direction.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/bdo
|
||||
*/
|
||||
class BdoTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'bdo';
|
||||
}
|
41
src/Html5/InlineTextSemantics/BrTag.php
Normal file
41
src/Html5/InlineTextSemantics/BrTag.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractTag;
|
||||
|
||||
/**
|
||||
* The <br> HTML element produces a line break in text (carriage-return). It is
|
||||
* useful for writing a poem or an address, where the division of lines is
|
||||
* significant.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/br
|
||||
*/
|
||||
class BrTag extends AbstractTag
|
||||
{
|
||||
const TAG = 'br';
|
||||
}
|
41
src/Html5/InlineTextSemantics/CiteTag.php
Normal file
41
src/Html5/InlineTextSemantics/CiteTag.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <cite> HTML element is used to mark up the title of a cited creative
|
||||
* work. The reference may be in an abbreviated form according to
|
||||
* context-appropriate conventions related to citation metadata.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/cite
|
||||
*/
|
||||
class CiteTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'cite';
|
||||
}
|
41
src/Html5/InlineTextSemantics/CodeTag.php
Normal file
41
src/Html5/InlineTextSemantics/CodeTag.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <code> HTML element displays its contents styled in a fashion intended to
|
||||
* indicate that the text is a short fragment of computer code. By default, the
|
||||
* content text is displayed using the user agent's default monospace font.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code
|
||||
*/
|
||||
class CodeTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'code';
|
||||
}
|
79
src/Html5/InlineTextSemantics/DataTag.php
Normal file
79
src/Html5/InlineTextSemantics/DataTag.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* The <data> HTML element links a given piece of content with a
|
||||
* machine-readable translation. If the content is time- or date-related, the
|
||||
* <time> element must be used.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data
|
||||
*/
|
||||
class DataTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'data';
|
||||
|
||||
/**
|
||||
* This attribute specifies the machine-readable translation of the content
|
||||
* of the element.
|
||||
*
|
||||
* @return null|string|Stringable
|
||||
*/
|
||||
public function value(): null|string|Stringable
|
||||
{
|
||||
return $this->attributes()->asString('value');
|
||||
}
|
||||
|
||||
/**
|
||||
* This attribute specifies the machine-readable translation of the content
|
||||
* of the element.
|
||||
*
|
||||
* @param null|string|Stringable $value
|
||||
* @return static
|
||||
*/
|
||||
public function setValue(null|string|Stringable $value): self
|
||||
{
|
||||
if ($value) $this->attributes()['value'] = $value;
|
||||
else $this->unsetValue();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This attribute specifies the machine-readable translation of the content
|
||||
* of the element.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function unsetValue(): self
|
||||
{
|
||||
unset($this->attributes()['value']);
|
||||
return $this;
|
||||
}
|
||||
}
|
99
src/Html5/InlineTextSemantics/DfnTag.php
Normal file
99
src/Html5/InlineTextSemantics/DfnTag.php
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* The <dfn> HTML element is used to indicate the term being defined within the
|
||||
* context of a definition phrase or sentence. The ancestor <p> element, the
|
||||
* <dt>/<dd> pairing, or the nearest <section> ancestor of the <dfn> element, is
|
||||
* considered to be the definition of the term.
|
||||
*
|
||||
* The term being defined is identified following these rules:
|
||||
*
|
||||
* * If the <dfn> element has a title attribute, the value of the title
|
||||
* attribute is considered to be the term being defined. The element must
|
||||
* still have text within it, but that text may be an abbreviation (perhaps
|
||||
* using <abbr>) or another form of the term.
|
||||
* * If the <dfn> contains a single child element and does not have any text
|
||||
* content of its own, and the child element is an <abbr> element with a
|
||||
* title attribute itself, then the exact value of the <abbr> element's title
|
||||
* is the term being defined.
|
||||
* * Otherwise, the text content of the <dfn> element is the term being
|
||||
* defined. This is shown in the first example below.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dfn
|
||||
*/
|
||||
class DataTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'dfn';
|
||||
|
||||
/**
|
||||
* If the <dfn> element has a title attribute, the value of the title
|
||||
* attribute is considered to be the term being defined. The element must
|
||||
* still have text within it, but that text may be an abbreviation (perhaps
|
||||
* using <abbr>) or another form of the term.
|
||||
*
|
||||
* @return null|string|Stringable
|
||||
*/
|
||||
public function title(): null|string|Stringable
|
||||
{
|
||||
return $this->attributes()->asString('title');
|
||||
}
|
||||
|
||||
/**
|
||||
* If the <dfn> element has a title attribute, the value of the title
|
||||
* attribute is considered to be the term being defined. The element must
|
||||
* still have text within it, but that text may be an abbreviation (perhaps
|
||||
* using <abbr>) or another form of the term.
|
||||
*
|
||||
* @param null|string|Stringable $title
|
||||
* @return static
|
||||
*/
|
||||
public function setTitle(null|string|Stringable $title): self
|
||||
{
|
||||
if ($title) $this->attributes()['title'] = $title;
|
||||
else $this->unsetTitle();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the <dfn> element has a title attribute, the value of the title
|
||||
* attribute is considered to be the term being defined. The element must
|
||||
* still have text within it, but that text may be an abbreviation (perhaps
|
||||
* using <abbr>) or another form of the term.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function unsetTitle(): self
|
||||
{
|
||||
unset($this->attributes()['title']);
|
||||
return $this;
|
||||
}
|
||||
}
|
53
src/Html5/InlineTextSemantics/EmTag.php
Normal file
53
src/Html5/InlineTextSemantics/EmTag.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <em> HTML element marks text that has stress emphasis. The <em> element
|
||||
* can be nested, with each level of nesting indicating a greater degree of
|
||||
* emphasis.
|
||||
*
|
||||
* The <em> element is for words that have a stressed emphasis compared to
|
||||
* surrounding text, which is often limited to a word or words of a sentence and
|
||||
* affects the meaning of the sentence itself.
|
||||
*
|
||||
* Typically this element is displayed in italic type. However, it should not be
|
||||
* used to apply italic styling; use the CSS font-style property for that
|
||||
* purpose. Use the <cite> element to mark the title of a work (book, play,
|
||||
* song, etc.). Use the <i> element to mark text that is in an alternate tone or
|
||||
* mood, which covers many common situations for italics such as scientific
|
||||
* names or words in other languages. Use the <strong> element to mark text that
|
||||
* has greater importance than surrounding text.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/em
|
||||
*/
|
||||
class EmTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'em';
|
||||
}
|
43
src/Html5/InlineTextSemantics/ITag.php
Normal file
43
src/Html5/InlineTextSemantics/ITag.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <i> HTML element represents a range of text that is set off from the
|
||||
* normal text for some reason, such as idiomatic text, technical terms,
|
||||
* taxonomical designations, among others. Historically, these have been
|
||||
* presented using italicized type, which is the original source of the <i>
|
||||
* naming of this element.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/i
|
||||
*/
|
||||
class ITag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'i';
|
||||
}
|
50
src/Html5/InlineTextSemantics/KbdTag.php
Normal file
50
src/Html5/InlineTextSemantics/KbdTag.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <kbd> HTML element represents a span of inline text denoting textual user
|
||||
* input from a keyboard, voice input, or any other text entry device. By
|
||||
* convention, the user agent defaults to rendering the contents of a <kbd>
|
||||
* element using its default monospace font, although this is not mandated by
|
||||
* the HTML standard.
|
||||
*
|
||||
* To describe an input comprised of multiple keystrokes, you can nest multiple
|
||||
* <kbd> elements, with an outer <kbd> element representing the overall input
|
||||
* and each individual keystroke or component of the input enclosed within its
|
||||
* own <kbd>, such as:
|
||||
*
|
||||
* <kbd><kbd>Ctrl</kbd>+<kbd>N</kbd></kbd>
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd
|
||||
*/
|
||||
class KbdTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'kbd';
|
||||
}
|
41
src/Html5/InlineTextSemantics/MarkTag.php
Normal file
41
src/Html5/InlineTextSemantics/MarkTag.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <mark> HTML element represents text which is marked or highlighted for
|
||||
* reference or notation purposes due to the marked passage's relevance in the
|
||||
* enclosing context.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark
|
||||
*/
|
||||
class MarkTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'mark';
|
||||
}
|
83
src/Html5/InlineTextSemantics/QTag.php
Normal file
83
src/Html5/InlineTextSemantics/QTag.php
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* The <q> HTML element indicates that the enclosed text is a short inline
|
||||
* quotation. Most modern browsers implement this by surrounding the text in
|
||||
* quotation marks. This element is intended for short quotations that don't
|
||||
* require paragraph breaks; for long quotations use the <blockquote> element.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/q
|
||||
*/
|
||||
class QTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'q';
|
||||
|
||||
/**
|
||||
* The value of this attribute is a URL that designates a source document or
|
||||
* message for the information quoted. This attribute is intended to point
|
||||
* to information explaining the context or the reference for the quote.
|
||||
*
|
||||
* @return null|string|Stringable
|
||||
*/
|
||||
public function cite(): null|string|Stringable
|
||||
{
|
||||
return $this->attributes()->asString('cite');
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of this attribute is a URL that designates a source document or
|
||||
* message for the information quoted. This attribute is intended to point
|
||||
* to information explaining the context or the reference for the quote.
|
||||
*
|
||||
* @param null|string|Stringable $cite
|
||||
* @return static
|
||||
*/
|
||||
public function setCite(null|string|Stringable $cite): self
|
||||
{
|
||||
if ($cite) $this->attributes()['cite'] = $cite;
|
||||
else $this->unsetCite();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of this attribute is a URL that designates a source document or
|
||||
* message for the information quoted. This attribute is intended to point
|
||||
* to information explaining the context or the reference for the quote.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function unsetCite(): self
|
||||
{
|
||||
unset($this->attributes()['cite']);
|
||||
return $this;
|
||||
}
|
||||
}
|
48
src/Html5/InlineTextSemantics/RpTag.php
Normal file
48
src/Html5/InlineTextSemantics/RpTag.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <rp> HTML element is used to provide fall-back parentheses for browsers
|
||||
* that do not support display of ruby annotations using the <ruby> element. One
|
||||
* <rp> element should enclose each of the opening and closing parentheses that
|
||||
* wrap the <rt> element that contains the annotation's text.
|
||||
*
|
||||
* Ruby annotations are for showing pronunciation of East Asian characters, like
|
||||
* using Japanese furigana or Taiwanese bopomofo characters. The <rp> element is
|
||||
* used in the case of lack of <ruby> element support; the <rp> content provides
|
||||
* what should be displayed in order to indicate the presence of a ruby
|
||||
* annotation, usually parentheses.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/rp
|
||||
*/
|
||||
class RpTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'rp';
|
||||
}
|
47
src/Html5/InlineTextSemantics/RtTag.php
Normal file
47
src/Html5/InlineTextSemantics/RtTag.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <rt> HTML element specifies the ruby text component of a ruby annotation,
|
||||
* which is used to provide pronunciation, translation, or transliteration
|
||||
* information for East Asian typography. The <rt> element must always be
|
||||
* contained within a <ruby> element.
|
||||
*
|
||||
* This simple example provides Romaji transliteration for the kanji characters
|
||||
* within the <ruby> element:
|
||||
*
|
||||
* <ruby> 漢 <rt>Kan</rt> 字 <rt>ji</rt> </ruby>
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/rt
|
||||
*/
|
||||
class RtTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'rt';
|
||||
}
|
55
src/Html5/InlineTextSemantics/RubyTag.php
Normal file
55
src/Html5/InlineTextSemantics/RubyTag.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <ruby> HTML element represents small annotations that are rendered above,
|
||||
* below, or next to base text, usually used for showing the pronunciation of
|
||||
* East Asian characters. It can also be used for annotating other kinds of
|
||||
* text, but this usage is less common.
|
||||
*
|
||||
* Example 1: Character:
|
||||
* ```
|
||||
* <ruby>
|
||||
* 漢 <rp>(</rp><rt>Kan</rt><rp>)</rp>
|
||||
* 字 <rp>(</rp><rt>ji</rt><rp>)</rp>
|
||||
* </ruby>
|
||||
* ```
|
||||
*
|
||||
* Example 2: Word
|
||||
* ```
|
||||
* <ruby> 明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp> </ruby>
|
||||
* ```
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ruby
|
||||
*/
|
||||
class RubyTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'ruby';
|
||||
}
|
47
src/Html5/InlineTextSemantics/STag.php
Normal file
47
src/Html5/InlineTextSemantics/STag.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <s> HTML element renders text with a strikethrough, or a line through it.
|
||||
* Use the <s> element to represent things that are no longer relevant or no
|
||||
* longer accurate. However, <s> is not appropriate when indicating document
|
||||
* edits; for that, use the <del> and <ins> elements, as appropriate.
|
||||
*
|
||||
* Accessibility concerns: The presence of the s element is not announced by
|
||||
* most screen reading technology in its default configuration. It can be made
|
||||
* to be announced by using the CSS content property, along with the ::before
|
||||
* and ::after pseudo-elements.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/s
|
||||
*/
|
||||
class STag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 's';
|
||||
}
|
42
src/Html5/InlineTextSemantics/SampTag.php
Normal file
42
src/Html5/InlineTextSemantics/SampTag.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <samp> HTML element is used to enclose inline text which represents
|
||||
* sample (or quoted) output from a computer program. Its contents are typically
|
||||
* rendered using the browser's default monospaced font (such as Courier or
|
||||
* Lucida Console).
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/samp
|
||||
*/
|
||||
class SampTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'samp';
|
||||
}
|
42
src/Html5/InlineTextSemantics/SmallTag.php
Normal file
42
src/Html5/InlineTextSemantics/SmallTag.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <small> HTML element represents side-comments and small print, like
|
||||
* copyright and legal text, independent of its styled presentation. By default,
|
||||
* it renders text within it one font-size smaller, such as from small to
|
||||
* x-small.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/small
|
||||
*/
|
||||
class SmallTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'small';
|
||||
}
|
45
src/Html5/InlineTextSemantics/SpanTag.php
Normal file
45
src/Html5/InlineTextSemantics/SpanTag.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <span> HTML element is a generic inline container for phrasing content,
|
||||
* which does not inherently represent anything. It can be used to group
|
||||
* elements for styling purposes (using the class or id attributes), or because
|
||||
* they share attribute values, such as lang. It should be used only when no
|
||||
* other semantic element is appropriate. <span> is very much like a <div>
|
||||
* element, but <div> is a block-level element whereas a <span> is an
|
||||
* inline-level element.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span
|
||||
*/
|
||||
class SpanTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'span';
|
||||
}
|
46
src/Html5/InlineTextSemantics/StrongTag.php
Normal file
46
src/Html5/InlineTextSemantics/StrongTag.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <strong> HTML element indicates that its contents have strong importance,
|
||||
* seriousness, or urgency. Browsers typically render the contents in bold type.
|
||||
*
|
||||
* The <strong> element is for content that is of "strong importance," including
|
||||
* things of great seriousness or urgency (such as warnings). This could be a
|
||||
* sentence that is of great importance to the whole page, or you could merely
|
||||
* try to point out that some words are of greater importance compared to nearby
|
||||
* content.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strong
|
||||
*/
|
||||
class StrongTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'strong';
|
||||
}
|
41
src/Html5/InlineTextSemantics/SubTag.php
Normal file
41
src/Html5/InlineTextSemantics/SubTag.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <sub> HTML element specifies inline text which should be displayed as
|
||||
* subscript for solely typographical reasons. Subscripts are typically rendered
|
||||
* with a lowered baseline using smaller text.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub
|
||||
*/
|
||||
class SubTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'sub';
|
||||
}
|
41
src/Html5/InlineTextSemantics/SupTag.php
Normal file
41
src/Html5/InlineTextSemantics/SupTag.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <sup> HTML element specifies inline text which is to be displayed as
|
||||
* superscript for solely typographical reasons. Superscripts are usually
|
||||
* rendered with a raised baseline using smaller text.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup
|
||||
*/
|
||||
class SupTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'sup';
|
||||
}
|
69
src/Html5/InlineTextSemantics/TimeTag.php
Normal file
69
src/Html5/InlineTextSemantics/TimeTag.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Html5\InlineTextSemantics\TimeTag\DatetimeValue;
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <time> HTML element represents a specific period in time. It may include
|
||||
* the datetime attribute to translate dates into machine-readable format,
|
||||
* allowing for better search engine results or custom features such as
|
||||
* reminders.
|
||||
*
|
||||
* It may represent one of the following:
|
||||
* * A time on a 24-hour clock.
|
||||
* * A precise date in the Gregorian calendar (with optional time and timezone
|
||||
* information).
|
||||
* * A valid time duration.
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time
|
||||
*/
|
||||
class TimeTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'time';
|
||||
|
||||
public function datetime(): null|DatetimeValue
|
||||
{
|
||||
return DatetimeValue::fromString(
|
||||
$this->attributes()->asString('datetime')
|
||||
);
|
||||
}
|
||||
|
||||
public function setDatetime(null|DatetimeValue $datetime): self
|
||||
{
|
||||
if ($datetime) $this->attributes()['datetime'] = $datetime;
|
||||
else $this->unsetDatetime();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function unsetDatetime(): self
|
||||
{
|
||||
unset($this->attributes()['datetime']);
|
||||
return $this;
|
||||
}
|
||||
}
|
99
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue.php
Normal file
99
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue.php
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics\TimeTag;
|
||||
|
||||
use Joby\HTML\Helpers\StringableValue;
|
||||
use Stringable;
|
||||
|
||||
abstract class DatetimeValue implements StringableValue
|
||||
{
|
||||
/** @var array<int,class-string<DatetimeValue>> */
|
||||
const SUBCLASSES = [
|
||||
DatetimeValue_datetime::class,
|
||||
DatetimeValue_datetime_local::class,
|
||||
DatetimeValue_time::class,
|
||||
DatetimeValue_year::class,
|
||||
DatetimeValue_month::class,
|
||||
DatetimeValue_date::class,
|
||||
DatetimeValue_date_yearless::class,
|
||||
DatetimeValue_week::class,
|
||||
DatetimeValue_duration::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Matches any sequence of at least four digits, optionally prefixed with a
|
||||
* dash for negative (BCE) years
|
||||
*/
|
||||
const REGEX_YEAR = '(?<year>(\-)?[0-9]{4,})';
|
||||
|
||||
/**
|
||||
* Matches any integer from 01 to 12, leading zero optional
|
||||
*/
|
||||
const REGEX_MONTH = '(?<month>0?[1-9]|1[0-2])';
|
||||
|
||||
/**
|
||||
* Matches any integer from 01 to 31, leading zero optional
|
||||
*/
|
||||
const REGEX_DAY = '(?<day>0?[1-9]|[0-2][0-9]|3[0-1])';
|
||||
|
||||
/**
|
||||
* Matches any integer from 01 to 53, leading zero optional
|
||||
*/
|
||||
const REGEX_WEEKNUM = '(?<weeknum>0?[1-9]|[1-4][0-9]|5[0-3])';
|
||||
|
||||
/**
|
||||
* Matches any integer from 00 to 59, leading zero optional
|
||||
*/
|
||||
const REGEX_HOUR = '(?<hour>0?[0-9]|1[0-9]|2[0-3])';
|
||||
|
||||
/**
|
||||
* Matches any integer from 00 to 59, leading zero optional
|
||||
*/
|
||||
const REGEX_MINUTE = '(?<minute>0?[0-9]|[1-5][0-9])';
|
||||
|
||||
/**
|
||||
* Matches any integer from 00 to 59, leading zero optional. Optionally
|
||||
* followed by a three-digit decimal portion.
|
||||
*/
|
||||
const REGEX_SECOND = '((?<second>0?[0-9]|[1-5][0-9])(\.(?<millisecond>[0-9]{3}))?)';
|
||||
|
||||
/**
|
||||
* Tries parsing with all subclasses and returns the first one that
|
||||
* succeeds, or null if nothing does.
|
||||
*
|
||||
* @param string|Stringable|null $string
|
||||
* @return null|self
|
||||
*/
|
||||
public static function fromString(string|Stringable|null $string): null|self
|
||||
{
|
||||
if (is_null($string)) return null;
|
||||
foreach (static::SUBCLASSES as $class) {
|
||||
$result = $class::fromString(strval($string));
|
||||
if ($result) return $result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
80
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue_date.php
Normal file
80
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue_date.php
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics\TimeTag;
|
||||
|
||||
use DateTime;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Holds a date that will be stringed to something like 2011-11-18
|
||||
*
|
||||
* Stored internally as a DateTime with the time set to noon, which is public
|
||||
* and as such can be conveniently manipulated.
|
||||
*/
|
||||
class DatetimeValue_date extends DatetimeValue
|
||||
{
|
||||
/** @var DateTime */
|
||||
public $datetime;
|
||||
|
||||
public static function fromString(string|Stringable|null $string): null|self
|
||||
{
|
||||
// null string returns null
|
||||
if (is_null($string)) return null;
|
||||
// try to match regular expression
|
||||
elseif (
|
||||
preg_match(
|
||||
sprintf(
|
||||
'/^%s\-%s\-%s$/',
|
||||
static::REGEX_YEAR,
|
||||
static::REGEX_MONTH,
|
||||
static::REGEX_DAY,
|
||||
),
|
||||
$string,
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
return new self(
|
||||
intval($matches['year']),
|
||||
intval($matches['month']),
|
||||
intval($matches['day']),
|
||||
);
|
||||
}
|
||||
// return null if nothing found
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __construct(int $year, int $month, int $day)
|
||||
{
|
||||
$this->datetime = (new DateTime())
|
||||
->setDate($year,$month,$day)
|
||||
->setTime(12,0,0,0);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->datetime->format('Y-m-d');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics\TimeTag;
|
||||
|
||||
use DateTime;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Holds a date that will be stringed to something like 11-18
|
||||
*
|
||||
* Stored internally as a DateTime with the time set to noon, which is public
|
||||
* and as such can be conveniently manipulated. Internally the year will be set
|
||||
* to the current year.
|
||||
*/
|
||||
class DatetimeValue_date_yearless extends DatetimeValue
|
||||
{
|
||||
/** @var DateTime */
|
||||
public $datetime;
|
||||
|
||||
public static function fromString(string|Stringable|null $string): null|self
|
||||
{
|
||||
// null string returns null
|
||||
if (is_null($string)) return null;
|
||||
// try to match regular expression
|
||||
elseif (
|
||||
preg_match(
|
||||
sprintf(
|
||||
'/^%s\-%s$/',
|
||||
static::REGEX_MONTH,
|
||||
static::REGEX_DAY,
|
||||
),
|
||||
$string,
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
return new self(
|
||||
intval($matches['month']),
|
||||
intval($matches['day']),
|
||||
);
|
||||
}
|
||||
// return null if nothing found
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __construct(int $month, int $day)
|
||||
{
|
||||
$this->datetime = (new DateTime())
|
||||
->setDate(intval(date('Y')), $month, $day)
|
||||
->setTime(12, 0, 0, 0);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->datetime->format('m-d');
|
||||
}
|
||||
}
|
107
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue_datetime.php
Normal file
107
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue_datetime.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics\TimeTag;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Holds a date/time that will be stringed to something like
|
||||
* 2011-11-18T14:54:39.929-0600
|
||||
*
|
||||
* Stored internally as a DateTime, which is public and as such can be
|
||||
* conveniently manipulated.
|
||||
*/
|
||||
class DatetimeValue_datetime extends DatetimeValue
|
||||
{
|
||||
/**
|
||||
* Matches either "Z" or a positive or negative offset from GMT in which the
|
||||
* colon is optional, such as +04:00 or -1030
|
||||
*/
|
||||
const REGEX_TIMEZONE = '(?<timezone>Z|(\+|\-)(0[0-9]|1[0-9]|2[0-3]):?(0[0-9]|[0-5][0-9]))';
|
||||
|
||||
public static function fromString(string|Stringable|null $string): null|self
|
||||
{
|
||||
// null string returns null
|
||||
if (is_null($string)) return null;
|
||||
// try to match regular expression
|
||||
elseif (
|
||||
preg_match(
|
||||
sprintf(
|
||||
'/^%s\-%s\-%s(T| )%s:%s(:%s)?%s$/i',
|
||||
static::REGEX_YEAR,
|
||||
static::REGEX_MONTH,
|
||||
static::REGEX_DAY,
|
||||
static::REGEX_HOUR,
|
||||
static::REGEX_MINUTE,
|
||||
static::REGEX_SECOND,
|
||||
static::REGEX_TIMEZONE,
|
||||
),
|
||||
$string,
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
return new self(
|
||||
(new DateTime())
|
||||
->setTimezone(
|
||||
self::parseTimezone($matches['timezone'])
|
||||
)
|
||||
->setDate(
|
||||
intval($matches['year']),
|
||||
intval($matches['month']),
|
||||
intval($matches['day'])
|
||||
)
|
||||
->setTime(
|
||||
intval($matches['hour']),
|
||||
intval($matches['minute']),
|
||||
intval(@$matches['second']),
|
||||
intval(@$matches['millisecond']) * 1000
|
||||
)
|
||||
);
|
||||
}
|
||||
// return null if nothing found
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static function parseTimezone(string $timezone): DateTimeZone
|
||||
{
|
||||
if ($timezone == 'Z' || $timezone == 'z') {
|
||||
return new DateTimeZone('UTC');
|
||||
} else {
|
||||
return new DateTimeZone(str_replace(':', '', $timezone));
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct(public DateTime $datetime)
|
||||
{
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->datetime->format('c');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics\TimeTag;
|
||||
|
||||
use DateTime;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Holds a date/time that will be stringed to something like
|
||||
* 2011-11-18T14:54:39.929 for use as a local time without an attached timezone.
|
||||
*
|
||||
* Stored internally as a DateTime, which is public and as such can be
|
||||
* conveniently manipulated.
|
||||
*/
|
||||
class DatetimeValue_datetime_local extends DatetimeValue
|
||||
{
|
||||
public static function fromString(string|Stringable|null $string): null|self
|
||||
{
|
||||
// null string returns null
|
||||
if (is_null($string)) return null;
|
||||
// try to match regular expression
|
||||
elseif (
|
||||
preg_match(
|
||||
sprintf(
|
||||
'/^%s\-%s\-%s(t|T| )%s:%s(:%s)?$/',
|
||||
static::REGEX_YEAR,
|
||||
static::REGEX_MONTH,
|
||||
static::REGEX_DAY,
|
||||
static::REGEX_HOUR,
|
||||
static::REGEX_MINUTE,
|
||||
static::REGEX_SECOND,
|
||||
),
|
||||
$string,
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
return new self(
|
||||
(new DateTime())
|
||||
->setDate(
|
||||
intval($matches['year']),
|
||||
intval($matches['month']),
|
||||
intval($matches['day'])
|
||||
)
|
||||
->setTime(
|
||||
intval($matches['hour']),
|
||||
intval($matches['minute']),
|
||||
intval(@$matches['second']),
|
||||
intval(@$matches['millisecond']) * 1000
|
||||
)
|
||||
);
|
||||
}
|
||||
// return null if nothing found
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __construct(public DateTime $datetime)
|
||||
{
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->datetime->format('Y-m-d\TH:i:s.v');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics\TimeTag;
|
||||
|
||||
use DateInterval;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Holds an interval/duration that will be stringed to something like PT4H18M3S
|
||||
*/
|
||||
class DatetimeValue_duration extends DatetimeValue
|
||||
{
|
||||
/**
|
||||
* Matches a valid duration period designation
|
||||
*/
|
||||
const REGEX_DURATION = "(<duration>P([0-9]+Y)?([0-9]+M)?([0-9]+[WD])?(T([0-9]+H)?([0-9]+M)?([0-9]+S)?)?)";
|
||||
|
||||
public static function fromString(string|Stringable|null $string): null|self
|
||||
{
|
||||
// null string returns null
|
||||
if (is_null($string)) return null;
|
||||
// try to construct
|
||||
try {
|
||||
return new self(
|
||||
new DateInterval(strval($string))
|
||||
);
|
||||
} catch (\Throwable $th) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct(protected DateInterval $interval)
|
||||
{
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
// format with all fields
|
||||
$string = $this->interval->format('P%yY%mM%dDT%hH%iM%sS');
|
||||
// strip out fields that are zero
|
||||
/** @var string */
|
||||
$string = preg_replace('/0[YMDHMS]/', '', $string);
|
||||
// strip trailing T if necessary
|
||||
if (str_ends_with($string, 'T')) $string = substr($string, 0, strlen($string) - 1);
|
||||
// return cleaned up value
|
||||
return $string;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics\TimeTag;
|
||||
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Holds a year/month pair that will be stringed to something like 2011-11
|
||||
*/
|
||||
class DatetimeValue_month extends DatetimeValue
|
||||
{
|
||||
public static function fromString(string|Stringable|null $string): null|self
|
||||
{
|
||||
// null string returns null
|
||||
if (is_null($string)) return null;
|
||||
// try to match regular expression
|
||||
elseif (
|
||||
preg_match(
|
||||
sprintf(
|
||||
'/^%s\-%s$/',
|
||||
static::REGEX_YEAR,
|
||||
static::REGEX_MONTH
|
||||
),
|
||||
$string,
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
return new self(
|
||||
intval($matches['year']),
|
||||
intval($matches['month'])
|
||||
);
|
||||
}
|
||||
// return null if nothing found
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __construct(public int $year, public int $week)
|
||||
{
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf(
|
||||
'%s%04d-%02d',
|
||||
$this->year < 0 ? '-' : '',
|
||||
abs($this->year),
|
||||
$this->week
|
||||
);
|
||||
}
|
||||
}
|
85
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue_time.php
Normal file
85
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue_time.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics\TimeTag;
|
||||
|
||||
use DateTime;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Holds a time that will be stringed to something like 14.54:39.929
|
||||
*
|
||||
* Stored internally as a DateTime with the date set to today, which is public
|
||||
* and as such can be conveniently manipulated.
|
||||
*/
|
||||
class DatetimeValue_time extends DatetimeValue
|
||||
{
|
||||
/** @var DateTime */
|
||||
public $datetime;
|
||||
|
||||
public static function fromString(string|Stringable|null $string): null|self
|
||||
{
|
||||
// null string returns null
|
||||
if (is_null($string)) return null;
|
||||
// try to match regular expression
|
||||
elseif (
|
||||
preg_match(
|
||||
sprintf(
|
||||
'/^%s:%s(:%s)?$/',
|
||||
static::REGEX_HOUR,
|
||||
static::REGEX_MINUTE,
|
||||
static::REGEX_SECOND,
|
||||
),
|
||||
$string,
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
return new self(
|
||||
intval($matches['hour']),
|
||||
intval($matches['minute']),
|
||||
intval(@$matches['second']),
|
||||
intval(@$matches['millisecond'])
|
||||
);
|
||||
}
|
||||
// return null if nothing found
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __construct(int $hour, int $minute, int $second = 0, int $millisecond = 0)
|
||||
{
|
||||
$this->datetime = (new DateTime())
|
||||
->setTime(
|
||||
$hour,
|
||||
$minute,
|
||||
$second,
|
||||
$millisecond * 1000
|
||||
);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->datetime->format('H:i:s.v');
|
||||
}
|
||||
}
|
73
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue_week.php
Normal file
73
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue_week.php
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics\TimeTag;
|
||||
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Holds a year/week pair that will be stringed to something like 2011-W47
|
||||
*/
|
||||
class DatetimeValue_week extends DatetimeValue
|
||||
{
|
||||
public static function fromString(string|Stringable|null $string): null|self
|
||||
{
|
||||
// null string returns null
|
||||
if (is_null($string)) return null;
|
||||
// try to match regular expression
|
||||
elseif (
|
||||
preg_match(
|
||||
sprintf(
|
||||
'/^%s\-W%s$/i',
|
||||
static::REGEX_YEAR,
|
||||
static::REGEX_WEEKNUM
|
||||
),
|
||||
$string,
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
return new self(
|
||||
intval($matches['year']),
|
||||
intval($matches['weeknum'])
|
||||
);
|
||||
}
|
||||
// return null if nothing found
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __construct(public int $year, public int $week)
|
||||
{
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf(
|
||||
'%s%04d-W%02d',
|
||||
$this->year < 0 ? '-' : '',
|
||||
abs($this->year),
|
||||
$this->week
|
||||
);
|
||||
}
|
||||
}
|
67
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue_year.php
Normal file
67
src/Html5/InlineTextSemantics/TimeTag/DatetimeValue_year.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics\TimeTag;
|
||||
|
||||
use Stringable;
|
||||
|
||||
class DatetimeValue_year extends DatetimeValue
|
||||
{
|
||||
public static function fromString(string|Stringable|null $string): null|self
|
||||
{
|
||||
// null string returns null
|
||||
if (is_null($string)) return null;
|
||||
// try to match regular expression
|
||||
elseif (
|
||||
preg_match(
|
||||
sprintf(
|
||||
'/^%s$/',
|
||||
static::REGEX_YEAR
|
||||
),
|
||||
$string,
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
return new self(
|
||||
intval($matches['year'])
|
||||
);
|
||||
}
|
||||
// return null if nothing found
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __construct(protected int $year)
|
||||
{
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf(
|
||||
'%s%04d',
|
||||
$this->year < 0 ? '-' : '',
|
||||
abs($this->year)
|
||||
);
|
||||
}
|
||||
}
|
59
src/Html5/InlineTextSemantics/UTag.php
Normal file
59
src/Html5/InlineTextSemantics/UTag.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Joby's HTML Object Strings: https://go.joby.lol/htmlobjectstrings
|
||||
* MIT License: Copyright (c) 2024 Joby Elliott
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Joby\HTML\Html5\InlineTextSemantics;
|
||||
|
||||
use Joby\HTML\Tags\AbstractContainerTag;
|
||||
|
||||
/**
|
||||
* The <u> HTML element represents a span of inline text which should be
|
||||
* rendered in a way that indicates that it has a non-textual annotation. This
|
||||
* is rendered by default as a simple solid underline, but may be altered using
|
||||
* CSS.
|
||||
*
|
||||
* Valid use cases for the <u> element include annotating spelling errors,
|
||||
* applying a proper name mark to denote proper names in Chinese text, and other
|
||||
* forms of annotation.
|
||||
*
|
||||
* You should not use <u> to underline text for presentation purposes, or to
|
||||
* denote titles of books.
|
||||
*
|
||||
* In most cases, you should use an element other than <u>, such as:
|
||||
*
|
||||
* * <em> to denote stress emphasis
|
||||
* * <b> to draw attention to text
|
||||
* * <mark> to mark key words or phrases
|
||||
* * <strong> to indicate that text has strong importance
|
||||
* * <cite> to mark the titles of books or other publications
|
||||
* * <i> to denote technical terms, transliterations, thoughts, or names of
|
||||
* vessels in Western texts
|
||||
*
|
||||
* Tag description by Mozilla Contributors licensed under CC-BY-SA 2.5
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/u
|
||||
*/
|
||||
class UTag extends AbstractContainerTag
|
||||
{
|
||||
const TAG = 'u';
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue