* * * 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:----CYP53OUVl3VQxTH70j3VNB8jsXqfKFWfpOQHFYsZiswcOVAFjh8aXTxdsdrGqr+iGpbbNmPNAtHcsY98yS/QCvsKWlDdKrCtgG6xVQKm+cUjAwDAUiXk8JieuBCaKUBe2KlRvqffOKhda8Y0NsCc0wevchdXTBC9gM/DR/UfGV58Mjq1+ejwKiR5XFn15KbqqJYbJKIaptrCgwKhVQigKktkRASJTq+BsoD3dOS5H1n399j3wpRhVZ9zRJK63J1V/LxVEjcj/6JS1obkqaFOBTKLKl99d7P9kt2+Zi1sbWx2MGmg44Mf+QnPeLlLEGPnMeuNxgke5qm8/Lwlv90BRTpzov/ASKro49TYKzlpSclaeZxCDv7PC7DyTW6YeYIwde5iL+C+H27M8+TEtqFAnYjDS+NfN7NOqUvYTzMDVlnOEQQ0nzOrQ8SlLGcMIOg3bqmaiNNnPNbYK1L5P+Czpoq2ylsUc4sxEbxbV9AjIsUdCYlX4BHQ92CQ4oA8ZYlhzfVQwNAAzQXyJXGy6vZfA+1yPe3UHSoFv9MJK2TLKbmybJeWB2KtaSrfURCi8+be/ZVNmXXeSwydA+hnPBePQeFbG/1zB91hluxROPj3R+qUspgvIq+FMc67aMJzQd8RWrhKxpVL4fSG06tHVcWr/Zs5bd4izLNIyp6NkYJglks=----ATTACHMENT:----Mzg4MzczMjQ0MTE3NjcxMCA1MTQxMzA0ODE0MDMyNjggNDYzMzQ3NjU4NTA1NzQ3OA==