Size validator for comment dimensions and margins
This commit is contained in:
parent
a16badbcc4
commit
06f7d3c8bd
|
|
@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Nothing.
|
- Provided a Size Helper class to validate size values (pt, px, em)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,13 +129,13 @@ class Comment implements IComparable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set comment width (CSS style, i.e. XXpx or YYpt).
|
* Set comment width (CSS style, i.e. XXpx or YYpt). Default unit is pt.
|
||||||
*/
|
*/
|
||||||
public function setWidth(string $width): self
|
public function setWidth(string $width): self
|
||||||
{
|
{
|
||||||
$result = new Size($width);
|
$width = new Size($width);
|
||||||
if ($result->valid()) {
|
if ($width->valid()) {
|
||||||
$this->width = $result->size() . $result->unit();
|
$this->width = (string) $width;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
@ -150,13 +150,13 @@ class Comment implements IComparable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set comment height (CSS style, i.e. XXpx or YYpt).
|
* Set comment height (CSS style, i.e. XXpx or YYpt). Default unit is pt.
|
||||||
*/
|
*/
|
||||||
public function setHeight(string $height): self
|
public function setHeight(string $height): self
|
||||||
{
|
{
|
||||||
$result = new Size($height);
|
$height = new Size($height);
|
||||||
if ($result->valid()) {
|
if ($height->valid()) {
|
||||||
$this->height = $result->size() . $result->unit();
|
$this->height = (string) $height;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
@ -171,13 +171,13 @@ class Comment implements IComparable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set left margin (CSS style, i.e. XXpx or YYpt).
|
* Set left margin (CSS style, i.e. XXpx or YYpt). Default unit is pt.
|
||||||
*/
|
*/
|
||||||
public function setMarginLeft(string $margin): self
|
public function setMarginLeft(string $margin): self
|
||||||
{
|
{
|
||||||
$result = new Size($margin);
|
$margin = new Size($margin);
|
||||||
if ($result->valid()) {
|
if ($margin->valid()) {
|
||||||
$this->marginLeft = $result->size() . $result->unit();
|
$this->marginLeft = (string) $margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
@ -192,13 +192,13 @@ class Comment implements IComparable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set top margin (CSS style, i.e. XXpx or YYpt).
|
* Set top margin (CSS style, i.e. XXpx or YYpt). Default unit is pt.
|
||||||
*/
|
*/
|
||||||
public function setMarginTop(string $margin): self
|
public function setMarginTop(string $margin): self
|
||||||
{
|
{
|
||||||
$result = new Size($margin);
|
$margin = new Size($margin);
|
||||||
if ($result->valid()) {
|
if ($margin->valid()) {
|
||||||
$this->marginTop = $result->size() . $result->unit();
|
$this->marginTop = (string) $margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,9 @@ class Size
|
||||||
{
|
{
|
||||||
return $this->unit;
|
return $this->unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return $this->size . $this->unit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue