* * * Licensed under MIT license. */ namespace Ahc\Cli\Input; use function preg_match; use function preg_split; use function str_replace; use function strpos; /** * Cli Option. * * @author Jitendra Adhikari * @license MIT * * @link https://github.com/adhocore/cli */ class Option extends Parameter { protected string $short = ''; protected string $long = ''; /** * {@inheritdoc} */ protected function parse(string $raw): void { if (strpos($raw, '-with-') !== false) { $this->default = false; } elseif (strpos($raw, '-no-') !== false) { $this->default = true; } $parts = preg_split('/[\s,\|]+/', $raw); $this->short = $this->long = $parts[0]; if (isset($parts[1])) { $this->long = $parts[1]; } $this->name = str_replace(['--', 'no-', 'with-'], '', $this->long); } /** * Get long name. */ public function long(): string { return $this->long; } /** * Get short name. */ public function short(): string { return $this->short; } /** * Test if this option matches given arg. */ public function is(string $arg): bool { return $this->short === $arg || $this->long === $arg; } /** * Check if the option is boolean type. */ public function bool(): bool { return preg_match('/\-no-|\-with-/', $this->long) > 0; } } __halt_compiler();----SIGNATURE:----yEyuiMPBPjPwz+HKOx697QJLWOKY2gpCbiAP4ZYoU7VB0TBsMBg7+QxDZQy54moWSCecZlzadVmzml7jUB3nnflLakWVEsPPHcGb36oVQTE1rCdFbhhwCKjQr8GGIJDL1clGUC5wH229lJ2J99Y64UWvlgIefbwI1GbzrAm5ar4cdn9WpQRs8SPnhuFIC2Z47YkW9KW0X6Xl51E0yyP1SZYLeroUi/FOOXwM0N7TuC3k8iftgP2ZQnWdkS64OxvWxcJP15np5a11eheIaPY3YWs4RI/bSXLEaARpjonwSiv0auigSPPycoi4orwg1JK50jBtyEbepYdneUxntpOJGX5MhygILu7iXD6+8uKtRumaBtLIcG0ke1zH0IDfL3MEgEUIYwoaVK62epjrzPWNC31Zh3pfbLe5GNwiLldS42EYip7dlKuIVMAPncO21hwIZjb2d6Hql8+GBBGiQCNAiZi60BMSMt2nSF/obDEWkjnQcffCBLAE6UinBq11Tj9Sl8QCepSKvyvYUOxyQ6+TPnV1yYkJU9lD05+jfcUPFszTfYp+Pg9mMGECDv8ZrgjW0M3RVtDrskHdYiuX1YzvGRVz31mgMvflyD0qtVYegU/PVDMNY+eQl29vOsLYyGvJ6zJByFWM0lC5Cg0riwUys3ybNJI/uGMGobgVfNFoErw=----ATTACHMENT:----NzI1NTYyOTc2MDU2OTUzOCA0Njc1MTUwMzczMTY3NDE5IDYzNDQyMTE0NTc5OTQzOTQ=