* @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(bool $withDefault = false): string { if (!$withDefault || null === $this->default || '' === $this->default) { return $this->desc; } return ltrim(t('%1$s [default: %2$s]', [$this->desc, json_encode($this->default)])); } /** * 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:----jem2DH3nUF/nEtWbqFrzU3dDS1m79UifxF8Ce51GWsfSoMvahWF0hYGR8xW1oBfOOxo0UIqLIGjXPcMt6Z2agnzBItGmqqtGvKUUjQU96EFVTjwm7VymR6ZNZJPLoXX5Li7y/c62hQAIAav1IiSxw8WKA8Y4x0Fjzpj/65sqICYNSdc7rEWXIguqV6nYjctBV2SaF8Dix2u+ixxPeMx2S3jPXgjiMQMruXH0Qajwdrt01YBYKgiewjEB8BtNMx2SG5sRUahCLcYPu0kHgNF5CoBKyJsyKtIey763DbGKik4bYS+5zCqQm+oBvA2Brit80x30QDt6SualZmt7G+xZo76mb59+7g2xZHJmq880P3+d3yTYwtbL/ty+E2ob+4o2MIyRD9pC2ycv6y7Ds7awvauXCBRKrFckTicZ8lUDkOhzqNQN1fmrh3rk5QZ77QNursdTSndfrfRCjWvU5VKwFrVTEJAr2hO5sZWzzkqsvwR51bW8pAttoHT6aS5ovzqUIX8g63EeqTrhswRZYbnbh+sM2fBEcTfb8kbJQpguPAZL6l0uBA0yqn2ocjHbFeh7oFfEiGYaVx/egLgVsX+q/kevJDs0QLb9ge7kL35wxLJq5u8YBV2t/TAaaNaQfj8C/37CMvCeY+L8DmIBA+ate/gxrVWr3b3oXwr0RSL5wKs=----ATTACHMENT:----ODI1MDQyMDE2Mzk0OTA1IDI5NzgwMTk0MTg0NTA5NTggMjA1NDMwNTY3Mzg4MTQ0OA==