You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.1 KiB
PHP

<?php
namespace Artmark\Forms\Attributes;
/**
* Description of SizeAttribute
*
* @author Andrey Pokidov <pokidov@e-traffic.ru>
*/
trait SizeAttribute
{
/**
*
* @var int
*/
private $size = 0;
/**
* HTML site attribute of the input tag
* @return int
*/
public function size()
{
return $this->size;
}
/**
*
* @return boolean
*/
public function hasSize()
{
return $this->size > 0;
}
/**
*
* @param int $newSize
* @return $this
*/
public function setSize($newSize)
{
$this->size = intval($newSize);
if ($this->size < 0) {
$this->size = 0;
}
return $this;
}
/**
*
* @return $this
*/
public function removeSize()
{
$this->size = 0;
return $this;
}
protected function appendSizeAttribute(array & $attributes)
{
if ($this->hasSize())
{
$attributes['size'] = $this->size;
}
}
}