Fluent interface for constructor so options can be added during construction

@see Options::__construct()
@param string   $short
@param string   $long
@param string   $mode
@return static
499817
public static function create($short, $long = null, $mode = GetOpt::NO_ARGUMENT)
    {
        return new static($short, $long, $mode);
    }
1046788
public static function load($mode)
    {
		if (!is_string($mode)){
			throw new InvalidArgumentException('Try to load an irregular mode in the context. The mode must be a string, ' . gettype($mode) . ' given.');
		}
    	else if (empty($mode)){
    		throw new InvalidArgumentException('Cannot load an empty mode in the context.');
    	}
    	
    	if(!in_array($mode, self::$current)){
    		self::$current[] = $mode;
    	}
    }
702322
public function open($mode = 'a') {
        if (is_resource($this->stream)) {
            return $this;
        }
        $this->stream = fopen($this->file->getFullName(), $mode);
        return $this;
    }
626798
public function create($options, Context $context = null)
    {
        $validators = [];
        if (!empty($options['required'])) {
            $validators[] = new PresenceOf();
        }
        $type = ArrayHelper::fetch($options, 'type');
        if (isset($type)) {
            if ($type == 'datetime') {
                $validators[] = new Datetime([
                    'pattern' => ArrayHelper::fetch($options, 'pattern')
                ]);
            } elseif (isset(self::$TYPES[$type])) {
                $validators[] = (new self::$TYPES[$type]([]))->getValidator($this->form);
            } elseif ($type == 'array') {
                $validators[] = (new IsArray([
                    'element' => ArrayHelper::fetch($options, 'element')
                ], $context))->getValidator($this->form);
            } else {
                if ($context) {
                    $type = (new ClassResolver($this->form->getCache()))
                           ->resolve($type, $context->getDeclaringClass());
                }
                if (class_exists($type)) {
                    if (is_subclass_of($type, ValidatorInterface::class)) {
                        $validators[] = new $type($options);
                    } else {
                        $validators[] = new IsA($this->form, ['class' => $type]);
                    }
                } else {
                    if ($this->logger) {
                        $this->logger->warning("unknown validator type {$type}");
                    }
                }
            }
        }
        if (isset($options['min']) || isset($options['max'])) {
            $validators[] = new Range([
                'min' => ArrayHelper::fetch($options, 'min'),
                'max' => ArrayHelper::fetch($options, 'max'),
                'exclusiveMinimum' => ArrayHelper::fetch($options, 'exclusiveMinimum'),
                'exclusiveMaximum' => ArrayHelper::fetch($options, 'exclusiveMaximum')
            ]);
        }
        if (isset($options['minLength']) || isset($options['maxLength'])) {
            $validators[] = new StringLength([
                'min' => ArrayHelper::fetch($options, 'minLength'),
                'max' => ArrayHelper::fetch($options, 'maxLength')
            ]);
        }
        if (isset($options['enum'])) {
            if (is_array($options['enum'])) {
                $validators[] = new InclusionIn(['domain' => $options['enum']]);
            } else {
                $validators[] = (new Enum([
                    'model' => $options['enum'],
                    'attribute' => ArrayHelper::fetch($options, 'attribute'),
                ], $context))->getValidator($this->form);
            }
        }
        if (isset($options['pattern']) && $type != 'datetime') {
            $validators[] = new Regex([ 'pattern' => $options['pattern'] ]);
        }
        return $validators;
    }
131997
public function openStream(string $mode): StreamInterface
    {
        try {
            $res = Thrower::call('fopen', $this, $mode);
        } catch (\Exception $e) {
            throw new \RuntimeException(sprintf('Unable to open %s using mode "%s"', $this, $mode), 0, $e);
        }

        return StreamFactoryDiscovery::find()->createStream($res);
    }
967229
public function addOptional(string $short, string $long, string $description = '', string $placeholder = 'value')
    {
        $this->addOption(self::OPTIONAL, $short, $long, $description, $placeholder);
        return $this;
    }
605046
public function addNoValue(string $short, string $long, string $description = '')
    {
        $this->addOption(self::NO_VALUE, $short, $long, $description, '');
        return $this;
    }
1249195
public static function setNewFileMode(string $mode = '740'): void
    {
        static::init();
        static::$newFileMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740;
    }
643640
public function create($mode = 0777) {

		if(false === ('-' . intval($mode) == '-' . $mode)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($mode)), E_USER_ERROR);
		}

		$paths = preg_split('#[\\/]#', $this -> directory -> getPath());
		$build = '';

		foreach($paths as $path) {

			$build .= $path . DIRECTORY_SEPARATOR;

			if(false === @is_dir($build)) {
				@mkdir($build, $mode);
			}
		}

		$this -> refresh();

		return $this;
	}
521150
protected function _createShell($className, $shortName)
    {
        $instance = parent::_createShell($className, $shortName);
        $webIo = new ConsoleIo(
            new WebConsoleOutput(),
            new WebConsoleOutput(),
            new WebConsoleInput()
        );
        $instance->io($webIo);

        return $instance;
    }
417417
public function short($short) {
        $this->validated = false;
        if (!self::validateShort($short)) {
            throw new OptionConfigException('short option must be a single character: ' . $short);
        }
        $this->config[self::SHORT] = $short;
        return $this;
    }
543201
public function newConditionCreateStruct(string $type): ConditionCreateStruct
    {
        $struct = new ConditionCreateStruct();
        $struct->type = $type;

        return $struct;
    }
1001171
public function addArg(string $name, int $mode = null, string $description = '', $default = null): self
    {
        return $this->addArgument($name, $mode, $description, $default);
    }
1326055
public function init( $config = NULL )
    {
        $option                   = new Option();
        $option->shortCode        = 'h';
        $option->longCode         = 'help';
        $option->isOptional       = TRUE;
        $option->type             = Type::BOOLEAN;
        $option->shortDescription = 'Show the help menu';

        $this->options[ ] = $option;

        $option                   = new Option();
        $option->shortCode        = 'v';
        $option->longCode         = 'verbose';
        $option->isOptional       = TRUE;
        $option->type             = Type::BOOLEAN;
        $option->shortDescription = 'Show detailed log';

        $this->options[ ] = $option;
    }
617166
public function mode($mode = null)
    {
        if ($mode !== null) {
            $this->mode = (string) $mode;
        }

        return $this->mode;
    }
104650
public function build(): SetInspectModeRequest
	{
		$instance = new SetInspectModeRequest();
		if ($this->mode === null) {
			throw new BuilderException('Property [mode] is required.');
		}
		$instance->mode = $this->mode;
		$instance->highlightConfig = $this->highlightConfig;
		return $instance;
	}
21855
public function setShort($short)
    {
        if (!(is_null($short) || preg_match("/^[a-zA-Z0-9?!§$%#]$/", $short))) {
            throw new \InvalidArgumentException(sprintf(
                'Short option must be null or one of [a-zA-Z0-9?!§$%%#], found \'%s\'',
                $short
            ));
        }
        $this->short = $short;
        return $this;
    }