* * * 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:----GIgropwiL3S9i01fhs7+4KTd6ymsvJa/fzqtZbSx9lXP/KJvm4Q3m6J1wIOiVuxCQga3HsdcZfuq4k1m+addxLuT2dqX8cbqXJXFsKKWpH3Er0DfZSVsUTiT+66n1kGrGO4nsoL01oEiwQqunlxzsaAZfcI+G5ehqVJxeprrBQECl5cZOTiQI80Oza+Rt7fWxuKWgoRagPkd0j78RLR+Ok0IQWn8EhLN0yo1VKYUJaWHuPCDM+ApD+kz/BLWraZ96GVXlaLXVdNNVUMrsmqxsAeRDGTXDDaDMBkxJ/Ul7hBWBu661DRfUFic+778+Ydz1fB7fIIa4td5knRAdHw98Jja3S/OuVR4dqBEdhjpyPe8y93AQQn9EBHZDw1uZTSOpxXeL6nM4Ks4o0ly73JWpGOoB/sGkaijoQ8n+lAYebQs+XEN7kruqVRCW1/ucttSowM2cDl6wXsT3v1ZZ7r89R0PuwWbjczfz7DrRgbOQp42dToACM0blX1ywhl97zvm390JZAuc/ZeUZCR534QD0jqdQ6BVG/AaKh0Kfvml79yzX80c3+K4wxZ8da5gqEalor22q1gaW+y9vZoDKYsdYKR0keMILqGvLksoSwQtc2f7Zi5Nq7BvZjd/Oo+/W7ZhmyT9C5NxZXaLDHfsxSL43QTQldO5WyfuVUOVzuTl4jw=----ATTACHMENT:----OTIxODEzNzI3MjQ0OTM0NCA4OTUxNjMyNzIzODUzMDY2IDU3MDQ0NjE2NzA2NDE0NTc=