* @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:----VZwiOWgf4jYy8W0A5NmzWPyVOmxSiRU2/cE/8p6Qo87AzIJRzqpNvtrlEcPG6fWxC6+oQorfJq8liaxsZ+tcp+t3ZAFreuJDFz2nG4EypmjBEtTsijJa3cOWjUL7pe4k1kcK2jHmbcg5HLa/TfaGhK9grOTfjcIMoA4VxftNAYKCM35cGDddYZpdgHzz8FFcImF17TKhUMzJWCmoxSIVXPEjzkOWdhs0mXoNvdJ/9cMt3IaWoBRAA0QwdQVyyrD/JFY1hf54Gus7GYlwHfc1zz3GdeFtRkagyiChclc3yF+zvO4Lrkeg9ztx6cv13zu9phArNRiLX4HFRGl87GT2AaLVSp/50HVLGk+VaIVK6ix9vZZ2NwnYgfgaPKtlPXcbzjhjj4GtqKr6a1dMyrZrY65dXiY7vMDg3M/NUWiKeQVnVCZ3CJ9Y3ENCz/X98lxWuHcGU0FZEKiYn4W5IO6usrQ9BWxoMZ8ZABLsJjC4hwpMTDAfUnS27IxEiW0aXbytd/q1eXzGD+xavqubnUQwa0tjuVa3IRCSa/ls+proVDI/VHt+V5P2kK0Hu0i7QwlGaHQDh06slMhKCJLgbcVz61jJXtOjfPPX1ckDV2QOUGdTemYolr0EgYGc4XLG9fgUMK8Bor5+3xC1/5QtDkNiF0adaiEnrhGJDMIaDieTR20=----ATTACHMENT:----NDA1NDA2OTQxNjQ1NDQxNCAzNjM5MzE2NzAxNTk1NjE2IDg1NjQ1OTMxNjYyNDI4MDk=