for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
*
*/
namespace flightlog\form;
* @author Laurent De Coninck <[email protected]>
abstract class BaseInput implements FormElementInterface
{
* @var string
private $name;
* @var array
private $options;
* @var string|int
private $value;
private $type;
* @param string $name
* @param string $type
* @param array $options
public function __construct($name, $type, array $options = [])
if (empty($name)) {
throw new \InvalidArgumentException('Name cannot be empty');
}
$this->name = $name;
$this->options = $options;
$this->type = $type;
* @inheritDoc
public function getType()
return $this->type;
public function getOptions()
return $this->options;
public function getName()
return $this->name;
public function getValue()
return $this->value;
public function setValue($value)
$this->value = $value;
* @param int|string $value
* @return $this
public function setAttribute($name, $value)
$this->options['attr'][$name] = $value;
return $this;
public function required(){
$this->options['attr']['required'] = 'required';
public function disable(){
$this->options['attr']['disabled'] = 'disabled';
* @param string $option
* @return string|int|boolean|null
public function getOption($option){
if(!isset($this->options[$option])){
return null;
return $this->options[$option];