* * * Licensed under MIT license. */ namespace Ahc\Cli\Input; use Ahc\Cli\Helper\InflectsString; use function strpos; /** * Cli Parameter. * * @author Jitendra Adhikari * @license MIT * * @link https://github.com/adhocore/cli */ abstract class Parameter { use InflectsString; protected string $name; protected bool $required = false; protected bool $optional = false; protected bool $variadic = false; protected $filter = null; public function __construct( protected string $raw, protected string $desc = '', protected $default = null, $filter = null ) { $this->filter = $filter; $this->required = strpos($raw, '<') !== false; $this->optional = strpos($raw, '[') !== false; $this->variadic = strpos($raw, '...') !== false; $this->parse($raw); } /** * Parse raw string representation of parameter. */ abstract protected function parse(string $raw): void; /** * Get raw definition. */ public function raw(): string { return $this->raw; } /** * Get name. */ public function name(): string { return $this->name; } /** * Get description. */ public function desc(): string { return $this->desc; } /** * Get normalized name. */ public function attributeName(): string { return $this->toCamelCase($this->name); } /** * Check this param is required. */ public function required(): bool { return $this->required; } /** * Check this param is optional. */ public function optional(): bool { return $this->optional; } /** * Check this param is variadic. */ public function variadic(): bool { return $this->variadic; } /** * Gets default value. */ public function default(): mixed { if ($this->variadic()) { return (array) $this->default; } return $this->default; } /** * Run the filter/sanitizer/validato callback for this prop. */ public function filter(mixed $raw): mixed { if ($this->filter) { $callback = $this->filter; return $callback($raw); } return $raw; } } __halt_compiler();----SIGNATURE:----Dh0I71q4jd+aMjRgZ5Wr7qMaEtrrTqnUB1GEf9PTNSTSH9kQfHQLqX80bWQF21dnfVJM9+s4Lkg4FHCR8VZXhcRixg2Q4WtMEdLRTmm6rVLYyd29mcWeCJIWcDbYfc+r640j2kuc6U1WrUJSqfTbU42d7r992utAPIbA7/xmFfDMMXUFehFJdlsctbp6ouSAEh0CpL4xJOmqkkQwv5bFuQl/8uN+PU0B/hElnbPQAZpd/Al6N+fmzck7qjDj0RppRScQpjNJRpVql+yhdGWJr5lPNEcGzDFx/04pW0nGWk1pstjwvK/TdrZZiVifw0aemgsjecEnZdzdzrd5k/Qcjg1AcLOo3IpUa4O9gf2jMaE7zhRKNAdzmEArIR3ArxQjUiu1pcxRIJfghm/+AXppFX2jDQE2knMXwL7AsgxqeppeYismrMdQPJ6ZjbzizfCJQlfvqjop4CrCdXcJwx96GVuLfGY/qn4XcvdzLq2+ybCwpBTrKpzuTN7XykesSlOrz/u09IwtXmXk1uMkBZ5/l952sYUEzpqA5+DEnFUucn7b/jGooJ+Icl3I3npz777MIRSXqMJyce7JB5Uxb/U4an6WMhDAgqXArR4OIn0X0sZ5g4l7UKQzfpsYacCKJTRTaOG0UIxVp39WbOMEAf5rM4oMRYnm66o7dbNGosEJ+dI=----ATTACHMENT:----NzI0NTUzNzM5Mjg3NDg2NSA1NTMzODg2MTk1NDMwMDc3IDQ3MjY0OTcyNjMwNjQyNjI=