* * * 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:----Tf5xuE/tI+p6pht97C2Pwtb23HZFjwrCM0X/1MuHZ/Nw62f5IT7MUNC1eoWZCq0BBc7fzmeVvsNxbIw757qdaYhBuotomYBWy05tJzbLBKL3U1f424TeBvt0bEKSX4h4lDeglSzfN/bMGhzo/RQN49XjGeBXr+QTNxerozAiYLCJHyTC66RyJikwnFTu6TaGnBK/kvQCtEmJ4hPcBAB46UGmjPkj3QRNbKsbsQloSjzPIc09D03OCuCaZsvKYIrimTyKnKyEROow/m8CIJxd7m4j/mxUdtNyY9l+jtpT+BYcJeIYBkcfTQ+NGN98JUecczCPq+GVPmwwvWYU6G6FKfA/ToBpN4cCHlQwhKzeYQLrLBSRk0i6K2TpLw8hEAre+F+7U7xopXcbfyfqh/CqWVT8ViMAP2TfKjF1CVnM4bCNhmIfRufrEQopCDXLg/IxIzyyNB10pEocABCYoZcRraFQpOO9kYzepAu/t7IMFFlekm7TUeYcashDbm0uK7JWTV8lp5pHg0hWnR4PAovGDFjAlzie6AJ5w+LT1zc4bp532UIsCGE1OZYggB/Z6HKmr/VaYmPN7qLeLkadzE6xUuaYlKk+Ibpd136jw/NSOsmuhFTZdQ6QRhNLIuqc33N5JzNsg7pdawEd474xntKcrKpy8NFm/UBYp/pHeV+GEv0=----ATTACHMENT:----MjM0NDMzMDA3NDY1NjgzMSA4Nzk5OTE0ODY1Nzk4NTc2IDE0NDU2NzU1MzE5NDUxNDM=