11
0
Fork 0
mirror of https://github.com/n3w/helpers-cli-input.git synced 2025-12-21 13:43:22 +00:00

Updated to work with more than just Argument and Option input types. Makes use of InputTypeFactory to allow addition of new types as needed. Added InputTypeFactory to help with loading input type classes

This commit is contained in:
Alannah Kearney 2019-05-24 17:16:49 +10:00
commit 9e27b52991
8 changed files with 144 additions and 143 deletions

View file

@ -12,22 +12,40 @@ abstract class AbstractInputType implements Interfaces\InputTypeInterface
protected $flags;
protected $description;
protected $validator;
protected $default;
protected $value;
public function __construct($name, int $flags = null, string $description = null, object $validator = null)
public function __construct(string $name = null, int $flags = null, string $description = null, object $validator = null, $default = null)
{
$this->name = $name;
$this->flags = $flags;
$this->description = $description;
$this->validator = $validator;
$this->default = $default;
}
public function __call($name, array $args = [])
public function __call($name, array $args=[])
{
if (empty($args)) {
return $this->$name;
}
$this->$name = $args[0];
return $this;
}
public function __get($name)
{
return $this->$name;
}
public function respondsTo(string $name): bool
{
return ($name == $this->name);
}
public function getType(): string
{
return strtolower((new \ReflectionClass(static::class))->getShortName());