private function parseOption(array $item) : Option
    {
        $name = $item['option'];

        $characteristic = $item['characteristic'] ?? null;

        if (isset($characteristic))
        {
            $characteristic = self::optionCharacteristic($characteristic);
        }

        $type = $item['type'] ?? null;

        $default = $item['default'] ?? null;

        $description = $item['description'] ?? null;

        $fixedName = $item['name'] ?? null;

        $option = new Option($name, $characteristic, $type, $default);

        if (isset($description))
        {
            $option->setDescription($description);
        }

        if (isset($fixedName))
        {
            if ($fixedName[0] === '-')
            {
                throw new OptionLoaderException(
                    "An option's fixed name may not start with a `-`.",
                    $item
                );
            }

            $option->setFixedName($fixedName);
        }

        if (isset($item['aliases']))
        {
            foreach ($item['aliases'] as $alias)
            {
                $aliasCharacteristic = $alias['characteristic'] ?? null;

                if (isset($aliasCharacteristic))
                {
                    $aliasCharacteristic = self::optionCharacteristic(
                        $aliasCharacteristic
                    );
                }

                $aliasName = $alias['option'] ?? null;

                if ( ! isset($aliasName))
                {
                    throw new OptionLoaderException(
                        "An alias must contain its own option name.",
                        $alias
                    );
                }

                new AliasOption($aliasName, $aliasCharacteristic, $option);
            }
        }

        if (isset($fixedName))
        {
            $this->optionCatalogue[$fixedName] = $option;
        }

        $this->optionCatalogue[$option->getPrintableName()] = $option;

        return $option;
    }
private function parseOption(array $item) : Option
    {
        $name = $item['option'];

        $characteristic = $item['characteristic'] ?? null;

        if (isset($characteristic))
        {
            $characteristic = self::optionCharacteristic($characteristic);
        }

        $type = $item['type'] ?? null;

        $default = $item['default'] ?? null;

        $description = $item['description'] ?? null;

        $fixedName = $item['name'] ?? null;

        $option = new Option($name, $characteristic, $type, $default);

        if (isset($description))
        {
            $option->setDescription($description);
        }

        if (isset($fixedName))
        {
            if ($fixedName[0] === '-')
            {
                throw new OptionLoaderException(
                    "An option's fixed name may not start with a `-`.",
                    $item
                );
            }

            $option->setFixedName($fixedName);
        }

        if (isset($item['aliases']))
        {
            foreach ($item['aliases'] as $alias)
            {
                $aliasCharacteristic = $alias['characteristic'] ?? null;

                if (isset($aliasCharacteristic))
                {
                    $aliasCharacteristic = self::optionCharacteristic(
                        $aliasCharacteristic
                    );
                }

                $aliasName = $alias['option'] ?? null;

                if ( ! isset($aliasName))
                {
                    throw new OptionLoaderException(
                        "An alias must contain its own option name.",
                        $alias
                    );
                }

                new AliasOption($aliasName, $aliasCharacteristic, $option);
            }
        }

        if (isset($fixedName))
        {
            $this->optionCatalogue[$fixedName] = $option;
        }

        $this->optionCatalogue[$option->getPrintableName()] = $option;

        return $option;
    }
private function parseOption ( array $ item ) : Option { $ name = $ item [ 'option' ] ; $ characteristic = $ item [ 'characteristic' ] ?? null ; if ( isset ( $ characteristic ) ) { $ characteristic = self :: optionCharacteristic ( $ characteristic ) ; } $ type = $ item [ 'type' ] ?? null ; $ default = $ item [ 'default' ] ?? null ; $ description = $ item [ 'description' ] ?? null ; $ fixedName = $ item [ 'name' ] ?? null ; $ option = new Option ( $ name , $ characteristic , $ type , $ default ) ; if ( isset ( $ description ) ) { $ option -> setDescription ( $ description ) ; } if ( isset ( $ fixedName ) ) { if ( $ fixedName [ 0 ] === '-' ) { throw new OptionLoaderException ( "An option's fixed name may not start with a `-`." , $ item ) ; } $ option -> setFixedName ( $ fixedName ) ; } if ( isset ( $ item [ 'aliases' ] ) ) { foreach ( $ item [ 'aliases' ] as $ alias ) { $ aliasCharacteristic = $ alias [ 'characteristic' ] ?? null ; if ( isset ( $ aliasCharacteristic ) ) { $ aliasCharacteristic = self :: optionCharacteristic ( $ aliasCharacteristic ) ; } $ aliasName = $ alias [ 'option' ] ?? null ; if ( ! isset ( $ aliasName ) ) { throw new OptionLoaderException ( "An alias must contain its own option name." , $ alias ) ; } new AliasOption ( $ aliasName , $ aliasCharacteristic , $ option ) ; } } if ( isset ( $ fixedName ) ) { $ this -> optionCatalogue [ $ fixedName ] = $ option ; } $ this -> optionCatalogue [ $ option -> getPrintableName ( ) ] = $ option ; return $ option ; }
Parse an option from file data structure

@param array $item

@return Option
Parse an option from file data structure