* * * 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:----mi0xsz+rbzYB+/cpVBOOqUUDOqSx5/XnRlLqZCRscROo20OiR8ljvcDqa2ofx+fb/uWC54/yB8xW36GSKNAEUzvkaDvSKyvhkNjiEo9IxYkjmgT6o4g35v96+1gjDIXZDL2mlvworerNF3sscedPLmrJlg83mpqaotHpZw14cyHhB9zJEDyt9rJUMkZfn9YALZsJTSaEasr5qsoXjDkMAVCb9hD2E0OADpxW/DtJRBiYd72lgXqPUxiEMolOAGfcRiw6yNFw19gJGDxP3O16tS7QMVl1KyZL3SudY4ihbjr2paaGknFXyJsGd6QuDn4Qlh+bmgZK3i3yu6xKS0M7vsNXUvCJGFthcBA7Aw0uGquRqhZjkBz19KUNjf/X/auZnQmBBMCernI+1SJbWQyWL4QVazvm54QVef7AOeuhs7eZXJXlFpN/EmMbn6h8u+ujgilx3MeUOzwsmLUrKpCiT+w2Eju2hQ/ZoS6FtrZ8V5pshGvcw90gqK8hnNjccU6iJpDRmITObbfnQ/v1x9DPWHQdk80G70+7xHXL01xl6OrB1netEzP/jEFEZxdwvOB4kbjlY43XnPcfoGTMOgb+T8EK+PGDoVD26XCCWjJzRypennSuitD6QAy1Pl9YCkrahp4mpqX1pjQARRfs698en3NB4pFjluSryxQt6mWLoos=----ATTACHMENT:----NjA1MzQzMzg5OTI1NDY4MCAxMzAyNTMyMzEyMjkzOTYwIDY4Mjg3MjE2ODAyNTE2MzM=