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

53 lines
1.1 KiB
PHP
Raw Normal View History

2019-05-20 15:08:41 +10:00
<?php
declare(strict_types=1);
namespace pointybeard\Helpers\Cli\Input;
abstract class AbstractInputType implements Interfaces\InputTypeInterface
{
protected static $type;
protected $name;
protected $flags;
protected $description;
protected $validator;
protected $default;
2019-05-20 15:08:41 +10:00
protected $value;
public function __construct(string $name = null, int $flags = null, string $description = null, object $validator = null, $default = null)
2019-05-20 15:08:41 +10:00
{
$this->name = $name;
$this->flags = $flags;
$this->description = $description;
$this->validator = $validator;
$this->default = $default;
2019-05-20 15:08:41 +10:00
}
public function __call($name, array $args=[])
{
if (empty($args)) {
return $this->$name;
}
$this->$name = $args[0];
return $this;
}
public function __get($name)
2019-05-20 15:08:41 +10:00
{
return $this->$name;
}
public function respondsTo(string $name): bool
{
return ($name == $this->name);
}
2019-05-20 15:08:41 +10:00
public function getType(): string
{
return strtolower((new \ReflectionClass(static::class))->getShortName());
}
}