* @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:----FN55vJ569fl64CjMJLHyG1+0A6s9pxP9S635R5x6E6aDpI8fcAZF8NSYzWfknAD17lBob3a++FyXhSxjejcSGsQaFBcnABqNzg0KI9JCebRb8W2d/Ice0QF5flnXarN1X60ZrJosdBQMN2iCpu2tFkwVlYMU+IwUz+E5SWwBaa2C8ixTmgYbXQH9PaVyJZZ2bQwtWRX7C0N0CzQOl6x1cC4BP7YZWR/6uQkjwTE4ENUlro6ysAozvm2llwPO2LmpU5VC8OJw8xy7z3xzmWdUisdJkal0JY0RlIzNjl+GP+aSXAuT1SCyrBFaaEl1NSajsskUInLDVQ2MVdeTVWPDyGM8jVLoh0/nwEH0z/TRp3VYESII+l8Q5/LWustAU9zrOL4edS/cISiADwiNrENZKpECh1FRVimMXJv6lLamljMcsoSs94kLkdQ3SLzXWw9hl0QVLTK3nqnkNXsqRHmfodqoonrIQLQF7Mmg+jDFjIMSRtQmoEuDgNrk7pdeIhdv4pHyEJfVeQE6fANElKu7/ofyYIWbJ3ydu2ZjmiWX6Zy0989ObM2n3WWU9SXKEP6x++ZQJNj5ZmioOug/OjogVeAzhipwUc0Vsp/zfJwDSvwx0fl7Xnjrh0Ltf0gLvMEI1p0f+hE6Bp721sq10YJH2b40a2/88LYQIxHWnc1w1+I=----ATTACHMENT:----NjMyMjQ2NjAxMTUyMDU0NyA3MjQ2MTIyMjgyNDgyNzk5IDg2Mzc2NjAwMTU0NDkyODc=