src/TweedeGolf/Generator/Console/Questioner.php
private function validateAndUpdateOptions(array $options, $type)
    {
        if (is_string($type)) {
            $type = $this->types->getType($type);
        }

        if (!($type instanceof InputTypeInterface)) {
            throw new InputTypeNotFoundException("Type should be an instance of InputTypeInterface or a string");
        }

        $defaults = $this->getDefaultOptions($type);
        foreach ($options as $key => $value) {
            if (!array_key_exists($key, $defaults)) {
                $allowed = implode(', ', array_keys($defaults));
                throw new InvalidInputException(
                    "Found non-default option '{$key}', only allowed to use one of {$allowed}."
                );
            }
        }
        return array_merge($defaults, $options);
    }
private function validateAndUpdateOptions(array $options, $type)
    {
        if (is_string($type)) {
            $type = $this->types->getType($type);
        }

        if (!($type instanceof InputTypeInterface)) {
            throw new InputTypeNotFoundException("Type should be an instance of InputTypeInterface or a string");
        }

        $defaults = $this->getDefaultOptions($type);
        foreach ($options as $key => $value) {
            if (!array_key_exists($key, $defaults)) {
                $allowed = implode(', ', array_keys($defaults));
                throw new InvalidInputException(
                    "Found non-default option '{$key}', only allowed to use one of {$allowed}."
                );
            }
        }
        return array_merge($defaults, $options);
    }
private function validateAndUpdateOptions ( array $ options , $ type ) { if ( is_string ( $ type ) ) { $ type = $ this -> types -> getType ( $ type ) ; } if ( ! ( $ type instanceof InputTypeInterface ) ) { throw new InputTypeNotFoundException ( "Type should be an instance of InputTypeInterface or a string" ) ; } $ defaults = $ this -> getDefaultOptions ( $ type ) ; foreach ( $ options as $ key => $ value ) { if ( ! array_key_exists ( $ key , $ defaults ) ) { $ allowed = implode ( ', ' , array_keys ( $ defaults ) ) ; throw new InvalidInputException ( "Found non-default option '{$key}', only allowed to use one of {$allowed}." ) ; } } return array_merge ( $ defaults , $ options ) ; }
Validate options does not contain non-existant options and update with defaults where not defined.
@param array                     $options
@param string|InputTypeInterface $type
@return array
@throws InvalidInputException
@throws InputTypeNotFoundException
Validate options does not contain non - existant options and update with defaults where not defined .