*/ 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; } } }