* * * 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:----bp3/XiMM50lbE7hUKDmDItD5NSctguCxaALYe6T7Rh2doTm7+poowt8GQ+uTdYqSxkyIp7O9Jbjx/DqqWnK3afuxnrhXJeDfdewCgCHZHtFsz61ZNEPLsO1tY2T7Dzq3IafkB1MKaGYCOD7iWtBD6TgCEU+paNn3FuXIx/gAhTAMRG2sG6GFlYFDvXx/toK7tecVPr5Yyv21cv+DGaIBw0JrhMs01zl3+Gu36i2BiTdMNXPwiDVz8MEl3bz0c1wO/brPuC4THjoCcoGd+JapnnyRaQmA7YoGdRnrT5RHo/21yCxjnES5L2lQFhtwyCjQqoneuwmgIFZw7oVdPmATpXa53ZDp4aiZVtTbl0d1tHRVd8Syvu8Fg+EUgklHu84QgKaihhhlxXdW0feiSX+PDdCb0j8cWp4L3Mh8S+uorVHfhgbmWAOli9Xp9Y1Oya/4Agf5efv04gS2s22QhUT48H4JtbKKm9BTzyC5dd5AK7z/wLlnT/wH/H9TyNmMJvJ8YAzoWikazPwPLFvp2eG9lBn/5gTFBaHbCGQz5ld+QXWzfhA3aCfYNMrKTp8JApH55a/uRLqEyNjmeYB6TK6UAdTacUooPoOgSy4+t/5NhCLdDOBlPXuM+vCGSG0hSX1coIkrq9cpmwnQ/tYtNKo+4i77uMpENS8H4mfiKLspquI=----ATTACHMENT:----NTkxODc3NTcwMTQyNjkxNiAxNzI1MzY5ODk5OTUwNDkxIDUwMTE1NjczNjgzMTg3OTM=