* @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:----LHSu9LTtxioFZwyZx694BCy+J8EUbNVe9ObwMgY66amL4cLH+oc7kUfxPKFeLxqI6XxjNhiDLQ21oWskLyMYjMRCmCerUzc3doCaXleNyXjKNfJXw4IhtdJVdED3l7u1XaCoZzflNhgbv+yeXiVveQKTMUYwVjfXWfmc++2WTkx9bjsXD/gia/PNJRgXlAcp8qudupQ36TSzlcbB538DdvYmXm9K825lh9YBYb2MaVpkRcyBCURUGf0hgWDgok8Q0HcyK5zHPyBbruaHNWLzZ9JS8mLP+n6Lyw1S4zRbDWX9VjknjX3ohJMk8mlgIPnL7Zoix2M7k/kMN/o69ZB0vm9ZPScOlXcIVgKoMBx5eqPuYMDH83LeFRLEOQLlmiTBTqZYwEO45ShHPnChAlke1xOYTCxjTm0AQrbwG8fCGmGUySc45yAmKJREHM3cGZj7WN3e71lvYursyMfcJ6D0a+otONJW+1qk193g+7vEWnVDCtzf60Yll+60pUZc5YVOryh3+oD0AxihsNVFMW+nI71X886Zo1bIE8kHfiE1aaxeVIMJJQOXm/c+cIkhj+ekwVRGYVusGhnu02YB9PWtQsvhpeoIik3a+uzWyHHhBXSXatL2LM7hvSyfuQy1MwDXJLCZcPhwQZk5SgahI3i+5szyAY7Ay61FTP1oY6IMa9A=----ATTACHMENT:----NjkzMDI4OTM2MzQ3MDM1OSAyMTM1MTg0NTgwNDE5NzA2IDUwOTg3Njk2NDQ2NTQxMjc=