diff --git a/src/Html5/Multimedia/EmbedTag.php b/src/Html5/Multimedia/EmbedTag.php index a9d27d8..308f5c2 100644 --- a/src/Html5/Multimedia/EmbedTag.php +++ b/src/Html5/Multimedia/EmbedTag.php @@ -2,6 +2,7 @@ namespace ByJoby\HTML\Html5\Multimedia; +use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait; use ByJoby\HTML\Tags\AbstractTag; use Stringable; @@ -19,45 +20,9 @@ use Stringable; */ class EmbedTag extends AbstractTag { + use HeightAndWidthTrait; const TAG = "embed"; - /** - * The displayed height of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @return null|integer - */ - public function height(): null|int - { - return $this->attributes()->asInt('height'); - } - - /** - * The displayed height of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @param null|integer $height - * @return self - */ - public function setHeight(null|int $height): self - { - if (is_int($height)) $this->attributes()['height'] = $height; - else $this->unsetHeight(); - return $this; - } - - /** - * The displayed height of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @return self - */ - public function unsetHeight(): self - { - unset($this->attributes()['height']); - return $this; - } - /** * The URL of the resource being embedded. * @@ -125,41 +90,4 @@ class EmbedTag extends AbstractTag unset($this->attributes()['type']); return $this; } - - /** - * The displayed width of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @return null|integer - */ - public function width(): null|int - { - return $this->attributes()->asInt('width'); - } - - /** - * The displayed width of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @param null|integer $width - * @return self - */ - public function setWidth(null|int $width): self - { - if (is_int($width)) $this->attributes()['width'] = $width; - else $this->unsetWidth(); - return $this; - } - - /** - * The displayed width of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @return self - */ - public function unsetWidth(): self - { - unset($this->attributes()['width']); - return $this; - } } \ No newline at end of file diff --git a/src/Html5/Multimedia/IframeTag.php b/src/Html5/Multimedia/IframeTag.php index 95b403d..d53add1 100644 --- a/src/Html5/Multimedia/IframeTag.php +++ b/src/Html5/Multimedia/IframeTag.php @@ -5,6 +5,7 @@ namespace ByJoby\HTML\Html5\Multimedia; use ByJoby\HTML\Helpers\StringableEnumArray; use ByJoby\HTML\Html5\Multimedia\IframeTag\ReferrerPolicyValue; use ByJoby\HTML\Html5\Multimedia\IframeTag\SandboxValue; +use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait; use ByJoby\HTML\Tags\AbstractTag; use Stringable; @@ -22,6 +23,7 @@ use Stringable; */ class IframeTag extends AbstractTag { + use HeightAndWidthTrait; const TAG = "embed"; /** @@ -221,40 +223,6 @@ class IframeTag extends AbstractTag return $this; } - /** - * The height of the frame in CSS pixels. Default is 150. - * - * @return null|integer - */ - public function height(): null|int - { - return $this->attributes()->asInt('height'); - } - - /** - * The height of the frame in CSS pixels. Default is 150. - * - * @param null|integer $height - * @return self - */ - public function setHeight(null|int $height): self - { - if (is_int($height)) $this->attributes()['height'] = $height; - else $this->unsetHeight(); - return $this; - } - - /** - * The height of the frame in CSS pixels. Default is 150. - * - * @return self - */ - public function unsetHeight(): self - { - unset($this->attributes()['height']); - return $this; - } - /** * The URL of the page to embed. Use a value of about:blank to embed an * empty page that conforms to the same-origin policy. Also note that @@ -340,38 +308,4 @@ class IframeTag extends AbstractTag unset($this->attributes()['srcdoc']); return $this; } - - /** - * The width of the frame in CSS pixels. Default is 300. - * - * @return null|integer - */ - public function width(): null|int - { - return $this->attributes()->asInt('width'); - } - - /** - * The width of the frame in CSS pixels. Default is 300. - * - * @param null|integer $width - * @return self - */ - public function setWidth(null|int $width): self - { - if (is_int($width)) $this->attributes()['width'] = $width; - else $this->unsetWidth(); - return $this; - } - - /** - * The width of the frame in CSS pixels. Default is 300. - * - * @return self - */ - public function unsetWidth(): self - { - unset($this->attributes()['width']); - return $this; - } } \ No newline at end of file diff --git a/src/Html5/Multimedia/ImgTag.php b/src/Html5/Multimedia/ImgTag.php index d236f8e..1588b22 100644 --- a/src/Html5/Multimedia/ImgTag.php +++ b/src/Html5/Multimedia/ImgTag.php @@ -6,6 +6,7 @@ use ByJoby\HTML\Helpers\BooleanAttribute; use ByJoby\HTML\Html5\Multimedia\ImgTag\DecodingValue; use ByJoby\HTML\Html5\Multimedia\ImgTag\ReferrerPolicyValue; use ByJoby\HTML\Html5\Traits\CrossOriginTrait; +use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait; use ByJoby\HTML\Tags\AbstractTag; use Stringable; @@ -18,6 +19,7 @@ use Stringable; class ImgTag extends AbstractTag { use CrossOriginTrait; + use HeightAndWidthTrait; const TAG = "img"; /** @@ -157,43 +159,6 @@ class ImgTag extends AbstractTag return $this; } - /** - * The intrinsic height of the image, in pixels. Must be an integer without - * a unit. - * - * @return null|integer - */ - public function height(): null|int - { - return $this->attributes()->asInt('height'); - } - - /** - * The intrinsic height of the image, in pixels. Must be an integer without - * a unit. - * - * @param null|integer $height - * @return self - */ - public function setHeight(null|int $height): self - { - if (is_int($height)) $this->attributes()['height'] = $height; - else $this->unsetHeight(); - return $this; - } - - /** - * The intrinsic height of the image, in pixels. Must be an integer without - * a unit. - * - * @return self - */ - public function unsetHeight(): self - { - unset($this->attributes()['height']); - return $this; - } - /** * This Boolean attribute indicates that the image is part of a server-side * map. If so, the coordinates where the user clicked on the image are sent @@ -482,43 +447,6 @@ class ImgTag extends AbstractTag return $this; } - /** - * The intrinsic width of the image in pixels. Must be an integer without a - * unit. - * - * @return null|integer - */ - public function width(): null|int - { - return $this->attributes()->asInt('width'); - } - - /** - * The intrinsic width of the image in pixels. Must be an integer without a - * unit. - * - * @param null|integer $width - * @return self - */ - public function setWidth(null|int $width): self - { - if (is_int($width)) $this->attributes()['width'] = $width; - else $this->unsetWidth(); - return $this; - } - - /** - * The intrinsic width of the image in pixels. Must be an integer without a - * unit. - * - * @return self - */ - public function unsetWidth(): self - { - unset($this->attributes()['width']); - return $this; - } - /** * The partial URL (starting with #) of an image map associated with the * element. diff --git a/src/Html5/Multimedia/ObjectTag.php b/src/Html5/Multimedia/ObjectTag.php index 6dc4628..03c991b 100644 --- a/src/Html5/Multimedia/ObjectTag.php +++ b/src/Html5/Multimedia/ObjectTag.php @@ -2,6 +2,7 @@ namespace ByJoby\HTML\Html5\Multimedia; +use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait; use ByJoby\HTML\Tags\AbstractTag; use Stringable; @@ -13,49 +14,13 @@ use Stringable; */ class ObjectTag extends AbstractTag { + use HeightAndWidthTrait; const TAG = "object"; // TODO data attribute // TODO form attribute // TODO usemap attribute - /** - * The displayed height of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @return null|integer - */ - public function height(): null|int - { - return $this->attributes()->asInt('height'); - } - - /** - * The displayed height of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @param null|integer $height - * @return self - */ - public function setHeight(null|int $height): self - { - if (is_int($height)) $this->attributes()['height'] = $height; - else $this->unsetHeight(); - return $this; - } - - /** - * The displayed height of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @return self - */ - public function unsetHeight(): self - { - unset($this->attributes()['height']); - return $this; - } - /** * The URL of the resource being embedded. * @@ -123,41 +88,4 @@ class ObjectTag extends AbstractTag unset($this->attributes()['type']); return $this; } - - /** - * The displayed width of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @return null|integer - */ - public function width(): null|int - { - return $this->attributes()->asInt('width'); - } - - /** - * The displayed width of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @param null|integer $width - * @return self - */ - public function setWidth(null|int $width): self - { - if (is_int($width)) $this->attributes()['width'] = $width; - else $this->unsetWidth(); - return $this; - } - - /** - * The displayed width of the resource, in CSS pixels. This must be an - * absolute value; percentages are not allowed. - * - * @return self - */ - public function unsetWidth(): self - { - unset($this->attributes()['width']); - return $this; - } } \ No newline at end of file diff --git a/src/Html5/Multimedia/SourceTag.php b/src/Html5/Multimedia/SourceTag.php index 2950436..0f3c19c 100644 --- a/src/Html5/Multimedia/SourceTag.php +++ b/src/Html5/Multimedia/SourceTag.php @@ -2,6 +2,7 @@ namespace ByJoby\HTML\Html5\Multimedia; +use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait; use ByJoby\HTML\Tags\AbstractTag; use Stringable; @@ -18,6 +19,9 @@ use Stringable; */ class SourceTag extends AbstractTag { + use HeightAndWidthTrait; + const TAG = "source"; + /** * The MIME media type of the image or other media type, optionally with a * codecs parameter. @@ -310,96 +314,4 @@ class SourceTag extends AbstractTag unset($this->attributes()['media']); return $this; } - - /** - * Allowed if the source element's parent is a element, but not - * allowed if the source element's parent is an