consolidated height/width helpers into a trait
This commit is contained in:
parent
f03493c8ff
commit
8b70867e40
8 changed files with 285 additions and 450 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace ByJoby\HTML\Html5\Multimedia;
|
namespace ByJoby\HTML\Html5\Multimedia;
|
||||||
|
|
||||||
|
use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait;
|
||||||
use ByJoby\HTML\Tags\AbstractTag;
|
use ByJoby\HTML\Tags\AbstractTag;
|
||||||
use Stringable;
|
use Stringable;
|
||||||
|
|
||||||
|
@ -19,45 +20,9 @@ use Stringable;
|
||||||
*/
|
*/
|
||||||
class EmbedTag extends AbstractTag
|
class EmbedTag extends AbstractTag
|
||||||
{
|
{
|
||||||
|
use HeightAndWidthTrait;
|
||||||
const TAG = "embed";
|
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.
|
* The URL of the resource being embedded.
|
||||||
*
|
*
|
||||||
|
@ -125,41 +90,4 @@ class EmbedTag extends AbstractTag
|
||||||
unset($this->attributes()['type']);
|
unset($this->attributes()['type']);
|
||||||
return $this;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ namespace ByJoby\HTML\Html5\Multimedia;
|
||||||
use ByJoby\HTML\Helpers\StringableEnumArray;
|
use ByJoby\HTML\Helpers\StringableEnumArray;
|
||||||
use ByJoby\HTML\Html5\Multimedia\IframeTag\ReferrerPolicyValue;
|
use ByJoby\HTML\Html5\Multimedia\IframeTag\ReferrerPolicyValue;
|
||||||
use ByJoby\HTML\Html5\Multimedia\IframeTag\SandboxValue;
|
use ByJoby\HTML\Html5\Multimedia\IframeTag\SandboxValue;
|
||||||
|
use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait;
|
||||||
use ByJoby\HTML\Tags\AbstractTag;
|
use ByJoby\HTML\Tags\AbstractTag;
|
||||||
use Stringable;
|
use Stringable;
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ use Stringable;
|
||||||
*/
|
*/
|
||||||
class IframeTag extends AbstractTag
|
class IframeTag extends AbstractTag
|
||||||
{
|
{
|
||||||
|
use HeightAndWidthTrait;
|
||||||
const TAG = "embed";
|
const TAG = "embed";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,40 +223,6 @@ class IframeTag extends AbstractTag
|
||||||
return $this;
|
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
|
* 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
|
* empty page that conforms to the same-origin policy. Also note that
|
||||||
|
@ -340,38 +308,4 @@ class IframeTag extends AbstractTag
|
||||||
unset($this->attributes()['srcdoc']);
|
unset($this->attributes()['srcdoc']);
|
||||||
return $this;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ use ByJoby\HTML\Helpers\BooleanAttribute;
|
||||||
use ByJoby\HTML\Html5\Multimedia\ImgTag\DecodingValue;
|
use ByJoby\HTML\Html5\Multimedia\ImgTag\DecodingValue;
|
||||||
use ByJoby\HTML\Html5\Multimedia\ImgTag\ReferrerPolicyValue;
|
use ByJoby\HTML\Html5\Multimedia\ImgTag\ReferrerPolicyValue;
|
||||||
use ByJoby\HTML\Html5\Traits\CrossOriginTrait;
|
use ByJoby\HTML\Html5\Traits\CrossOriginTrait;
|
||||||
|
use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait;
|
||||||
use ByJoby\HTML\Tags\AbstractTag;
|
use ByJoby\HTML\Tags\AbstractTag;
|
||||||
use Stringable;
|
use Stringable;
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ use Stringable;
|
||||||
class ImgTag extends AbstractTag
|
class ImgTag extends AbstractTag
|
||||||
{
|
{
|
||||||
use CrossOriginTrait;
|
use CrossOriginTrait;
|
||||||
|
use HeightAndWidthTrait;
|
||||||
const TAG = "img";
|
const TAG = "img";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,43 +159,6 @@ class ImgTag extends AbstractTag
|
||||||
return $this;
|
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
|
* 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
|
* map. If so, the coordinates where the user clicked on the image are sent
|
||||||
|
@ -482,43 +447,6 @@ class ImgTag extends AbstractTag
|
||||||
return $this;
|
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
|
* The partial URL (starting with #) of an image map associated with the
|
||||||
* element.
|
* element.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace ByJoby\HTML\Html5\Multimedia;
|
namespace ByJoby\HTML\Html5\Multimedia;
|
||||||
|
|
||||||
|
use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait;
|
||||||
use ByJoby\HTML\Tags\AbstractTag;
|
use ByJoby\HTML\Tags\AbstractTag;
|
||||||
use Stringable;
|
use Stringable;
|
||||||
|
|
||||||
|
@ -13,49 +14,13 @@ use Stringable;
|
||||||
*/
|
*/
|
||||||
class ObjectTag extends AbstractTag
|
class ObjectTag extends AbstractTag
|
||||||
{
|
{
|
||||||
|
use HeightAndWidthTrait;
|
||||||
const TAG = "object";
|
const TAG = "object";
|
||||||
|
|
||||||
// TODO data attribute
|
// TODO data attribute
|
||||||
// TODO form attribute
|
// TODO form attribute
|
||||||
// TODO usemap 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.
|
* The URL of the resource being embedded.
|
||||||
*
|
*
|
||||||
|
@ -123,41 +88,4 @@ class ObjectTag extends AbstractTag
|
||||||
unset($this->attributes()['type']);
|
unset($this->attributes()['type']);
|
||||||
return $this;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace ByJoby\HTML\Html5\Multimedia;
|
namespace ByJoby\HTML\Html5\Multimedia;
|
||||||
|
|
||||||
|
use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait;
|
||||||
use ByJoby\HTML\Tags\AbstractTag;
|
use ByJoby\HTML\Tags\AbstractTag;
|
||||||
use Stringable;
|
use Stringable;
|
||||||
|
|
||||||
|
@ -18,6 +19,9 @@ use Stringable;
|
||||||
*/
|
*/
|
||||||
class SourceTag extends AbstractTag
|
class SourceTag extends AbstractTag
|
||||||
{
|
{
|
||||||
|
use HeightAndWidthTrait;
|
||||||
|
const TAG = "source";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The MIME media type of the image or other media type, optionally with a
|
* The MIME media type of the image or other media type, optionally with a
|
||||||
* codecs parameter.
|
* codecs parameter.
|
||||||
|
@ -310,96 +314,4 @@ class SourceTag extends AbstractTag
|
||||||
unset($this->attributes()['media']);
|
unset($this->attributes()['media']);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Allowed if the source element's parent is a <picture> element, but not
|
|
||||||
* allowed if the source element's parent is an <audio> or <video> element.
|
|
||||||
*
|
|
||||||
* 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');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allowed if the source element's parent is a <picture> element, but not
|
|
||||||
* allowed if the source element's parent is an <audio> or <video> element.
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allowed if the source element's parent is a <picture> element, but not
|
|
||||||
* allowed if the source element's parent is an <audio> or <video> element.
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allowed if the source element's parent is a <picture> element, but not
|
|
||||||
* allowed if the source element's parent is an <audio> or <video> element.
|
|
||||||
*
|
|
||||||
* 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');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allowed if the source element's parent is a <picture> element, but not
|
|
||||||
* allowed if the source element's parent is an <audio> or <video> element.
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allowed if the source element's parent is a <picture> element, but not
|
|
||||||
* allowed if the source element's parent is an <audio> or <video> element.
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
namespace ByJoby\HTML\Html5\Multimedia;
|
namespace ByJoby\HTML\Html5\Multimedia;
|
||||||
|
|
||||||
use ByJoby\HTML\Helpers\BooleanAttribute;
|
use ByJoby\HTML\Helpers\BooleanAttribute;
|
||||||
|
use ByJoby\HTML\Html5\Traits\HeightAndWidthTrait;
|
||||||
use Stringable;
|
use Stringable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,42 +16,9 @@ use Stringable;
|
||||||
*/
|
*/
|
||||||
class VideoTag extends AbstractPlaybackTag
|
class VideoTag extends AbstractPlaybackTag
|
||||||
{
|
{
|
||||||
|
use HeightAndWidthTrait;
|
||||||
const TAG = 'video';
|
const TAG = 'video';
|
||||||
|
|
||||||
/**
|
|
||||||
* The height of the video's display area, in CSS pixels
|
|
||||||
*
|
|
||||||
* @return null|integer
|
|
||||||
*/
|
|
||||||
public function height(): null|int
|
|
||||||
{
|
|
||||||
return $this->attributes()->asInt('height');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The height of the video's display area, in CSS pixels
|
|
||||||
*
|
|
||||||
* @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 video's display area, in CSS pixels
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function unsetHeight(): self
|
|
||||||
{
|
|
||||||
unset($this->attributes()['height']);
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Boolean attribute indicating that the video is to be played "inline",
|
* A Boolean attribute indicating that the video is to be played "inline",
|
||||||
* that is within the element's playback area. Note that the absence of this
|
* that is within the element's playback area. Note that the absence of this
|
||||||
|
@ -119,38 +87,4 @@ class VideoTag extends AbstractPlaybackTag
|
||||||
unset($this->attributes()['poster']);
|
unset($this->attributes()['poster']);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The width of the video's display area, in CSS pixels
|
|
||||||
*
|
|
||||||
* @return null|integer
|
|
||||||
*/
|
|
||||||
public function width(): null|int
|
|
||||||
{
|
|
||||||
return $this->attributes()->asInt('width');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The width of the video's display area, in CSS pixels
|
|
||||||
*
|
|
||||||
* @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 video's display area, in CSS pixels
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function unsetWidth(): self
|
|
||||||
{
|
|
||||||
unset($this->attributes()['width']);
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
79
src/Html5/Traits/HeightAndWidthTrait.php
Normal file
79
src/Html5/Traits/HeightAndWidthTrait.php
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ByJoby\HTML\Html5\Traits;
|
||||||
|
|
||||||
|
trait HeightAndWidthTrait {
|
||||||
|
/**
|
||||||
|
* 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 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;
|
||||||
|
}
|
||||||
|
}
|
192
tests/Containers/test.svg
Normal file
192
tests/Containers/test.svg
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="200"
|
||||||
|
height="200"
|
||||||
|
viewBox="0 0 200 200"
|
||||||
|
version="1.1"
|
||||||
|
id="svg1"
|
||||||
|
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview1"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="false"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
showguides="true"
|
||||||
|
inkscape:zoom="2.3267609"
|
||||||
|
inkscape:cx="94.552044"
|
||||||
|
inkscape:cy="68.980014"
|
||||||
|
inkscape:window-width="1736"
|
||||||
|
inkscape:window-height="1023"
|
||||||
|
inkscape:window-x="141"
|
||||||
|
inkscape:window-y="177"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="layer1" />
|
||||||
|
<defs
|
||||||
|
id="defs1" />
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<g
|
||||||
|
id="g3">
|
||||||
|
<rect
|
||||||
|
style="fill:#0000ff;stroke-width:0.188982"
|
||||||
|
id="rect1"
|
||||||
|
width="28.571428"
|
||||||
|
height="25"
|
||||||
|
x="0"
|
||||||
|
y="-150"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#000000;stroke-width:0.188982"
|
||||||
|
id="rect1-6"
|
||||||
|
width="28.571428"
|
||||||
|
height="25"
|
||||||
|
x="28.571428"
|
||||||
|
y="-150"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#ff00ff;stroke-width:0.188982"
|
||||||
|
id="rect1-61"
|
||||||
|
width="28.571428"
|
||||||
|
height="25"
|
||||||
|
x="57.142857"
|
||||||
|
y="-150"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#000000;stroke-width:0.188982"
|
||||||
|
id="rect1-6-8"
|
||||||
|
width="28.571428"
|
||||||
|
height="25"
|
||||||
|
x="85.714287"
|
||||||
|
y="-150"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#00ffff;stroke-width:0.188982"
|
||||||
|
id="rect1-61-0"
|
||||||
|
width="28.571428"
|
||||||
|
height="25"
|
||||||
|
x="114.28571"
|
||||||
|
y="-150"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#000000;stroke-width:0.188982"
|
||||||
|
id="rect1-6-8-2"
|
||||||
|
width="28.571428"
|
||||||
|
height="25"
|
||||||
|
x="142.85715"
|
||||||
|
y="-150"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#000080;stroke-width:0.447214"
|
||||||
|
id="rect2"
|
||||||
|
width="40"
|
||||||
|
height="50"
|
||||||
|
x="0"
|
||||||
|
y="150" />
|
||||||
|
<rect
|
||||||
|
style="fill:#f2f2f2;stroke-width:0.632456"
|
||||||
|
id="rect3"
|
||||||
|
width="40"
|
||||||
|
height="50"
|
||||||
|
x="40"
|
||||||
|
y="150" />
|
||||||
|
<rect
|
||||||
|
style="fill:#cccccc;stroke-width:0.188982"
|
||||||
|
id="rect1-61-0-9"
|
||||||
|
width="28.571428"
|
||||||
|
height="25"
|
||||||
|
x="171.42857"
|
||||||
|
y="-150"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#cccccc;stroke-width:0.422577"
|
||||||
|
id="rect1-1"
|
||||||
|
width="28.571428"
|
||||||
|
height="125"
|
||||||
|
x="0"
|
||||||
|
y="-125"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#808000;stroke-width:0.422577"
|
||||||
|
id="rect1-6-2"
|
||||||
|
width="28.571428"
|
||||||
|
height="125"
|
||||||
|
x="28.571428"
|
||||||
|
y="-125"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#008080;stroke-width:0.422577"
|
||||||
|
id="rect1-61-9"
|
||||||
|
width="28.571428"
|
||||||
|
height="125"
|
||||||
|
x="57.142857"
|
||||||
|
y="-125"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#008000;stroke-width:0.422577"
|
||||||
|
id="rect1-6-8-3"
|
||||||
|
width="28.571428"
|
||||||
|
height="125"
|
||||||
|
x="85.714287"
|
||||||
|
y="-125"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#800080;stroke-width:0.422577"
|
||||||
|
id="rect1-61-0-1"
|
||||||
|
width="28.571428"
|
||||||
|
height="125"
|
||||||
|
x="114.28571"
|
||||||
|
y="-125"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#800000;stroke-width:0.422577"
|
||||||
|
id="rect1-6-8-2-9"
|
||||||
|
width="28.571428"
|
||||||
|
height="125"
|
||||||
|
x="142.85715"
|
||||||
|
y="-125"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#000080;stroke-width:0.422577"
|
||||||
|
id="rect1-61-0-9-4"
|
||||||
|
width="28.571428"
|
||||||
|
height="125"
|
||||||
|
x="171.42857"
|
||||||
|
y="-125"
|
||||||
|
transform="scale(1,-1)" />
|
||||||
|
<rect
|
||||||
|
style="fill:#800080;stroke-width:0.632456"
|
||||||
|
id="rect3-5"
|
||||||
|
width="40"
|
||||||
|
height="50"
|
||||||
|
x="80"
|
||||||
|
y="150" />
|
||||||
|
<rect
|
||||||
|
style="fill:#4d4d4d;stroke-width:0.632456"
|
||||||
|
id="rect3-5-2"
|
||||||
|
width="40"
|
||||||
|
height="50"
|
||||||
|
x="120"
|
||||||
|
y="150" />
|
||||||
|
<rect
|
||||||
|
style="fill:#1a1a1a;stroke-width:0.632456"
|
||||||
|
id="rect3-5-2-7"
|
||||||
|
width="40"
|
||||||
|
height="50"
|
||||||
|
x="160"
|
||||||
|
y="150" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 4.9 KiB |
Loading…
Reference in a new issue