* * * 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:----bhbK9RqAK1UZx6cJ94XTQ862JhRT6WGOt7lxnM3IUArvDbYM9kLnkTN30SCpnhbLHZNi+0O28s/BC/0l4j5PR6KaKqhNC5XWBMNGElJLY2T3y+2yU+W8EGU28T62001HctkZMfxQoJj/kbkFnLo1IaR7SeQS3naefP3YMCt5dGxVII/pxGdtMULwuQxqikADEJgn0bevMKGjMIJDX0ALACGm1JfJFGLgG1imKAv1kLjlI0aKg8N2rCNjCsD5epUfpcsD832kr6Vc/3ib6dk68tqEAjh2SNu+JwIsvlYLG90V29NJr49QpPtxfX9cbQ37LKVr5u0m+rA+pYsU1baasWXFrwCWzsg9lKrimmMwwdjsGJmmOnD7GfHYFQbmvg5gVNoReEx6A2y1TubpL6x9fMKIMioPw95DgQEPnccNy10oxHijfEj7ebl7sH5DC3rDrbgrare40qZKWXdMLOsN0vVozNK5OEfrVp0L272/57OU2grX9ORTD3JyyVqWd4TCz7zaxCDbpHc0cBvsJKvR5QNfkdlhwV7tBs3sLSlmvv1RsYbmbZIhXgI5wk5GxBIOjJPRYTnTWYeUKALQkXOdWj9s1Y1MXqs9P6vf3pGghRrnalUrOYo3f66soUyAAw8R7/NfYRyiV+P9lDWOJe8sOxmzMSOcYRTY/suC3voBCEo=----ATTACHMENT:----NzI0NTQzMTQxMzQ4ODg0IDkxODAxMTI1NjgyNDQyODEgMjcxODM1NDM1NTM1NTgyNw==