示例#1
0
文件: Option.php 项目: alxmsl/cli
 /**
  * @param string $long long name of option
  * @param bool $short short name of option
  * @param string $description description of option. Default value is empty
  * @param int $type option value type. Default value is boolean
  * @param bool $required option requirements. Default value is false
  * @throws UnexpectedValueException if value name is empty
  */
 public function __construct($long, $short, $description = '', $type = self::TYPE_BOOLEAN, $required = false)
 {
     parent::__construct($description, $required);
     $this->long = (string) $long;
     if (empty($this->long)) {
         throw new UnexpectedValueException();
     }
     $this->short = substr($short, 0, 1);
     if (empty($this->short)) {
         throw new UnexpectedValueException();
     }
     $this->type = (int) $type;
     $this->checkType($type);
 }