* @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(sprintf('%s [default: %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:----aPtlfbU8oJ4yrUyz1dpxe0JHWeGoZK1AwPxssyiTFZPGvKG04LwCcozhRBTyEaE2xoca04xBfW4winYmH7tfAbaZ5wH7gpyq8e3vAW2OSOWFY22W/D06u1lAB1edbndSYmvQCT/EYGbXB0CZ1w1j6dGj2mOiHO2rmCATs9sHmi0H3mRM4QuhZ58ViUbU1ZXBZ4YqVcpE6q9ZBYLtHb7r7o0cy76ulGkhWAKLVcwD35KXybCmwZ3yUMPmHeSi/QAz6bJSxD2u+YD4EbpzO6X6maXiJBV+KKVbBjnRdnae5ecgZ3o8s2d52iH4iM+B3m7tfU+ligdVfzZ4TarBl6AhA4O2irwIOjxtoxqQFto4Hakr7Yxq2wdJvJgWEer3p+eSh8x8tMVbonrQldIXsNAoIOh/G6IFy3zlgltxK36sx9gdWwTbe7Xli9L8HFthq5/W9qhgDfRaL7ceySbcqy0GaPF1zoQYurA2KCquBK8+Sm+DEd+zl5BFMFnihkRY1mDpfoGMXqhQ3VvfgwZYIuX7VOp8+sCMxjXqqg6idUE55Vvq6HGzrTt+Uqda7mNKcSCRbyDuf7TgcBVZ/m6fyBedqlo2nDCfEWRF6MQBbrMNjKFZZV548HEuJhYKgilEpaWOsLXUQHyoWqLNq6pu2/x9Y2Ny9Ebq8cwWKB2OuSL6ogA=----ATTACHMENT:----NjU0Nzc2NzYzOTgyMjY0OCA1ODQxMDEyNzU3MjQ3NzgyIDIyNTc5NTc2Mjg4MDkwMTI=