src/DunitCommand.php
private function getCurrentOptions(InputInterface $input, OutputInterface $output)
    {
        $options = $this->getDefaultOptions();
        try {
            $options = $this->mergeConfigFileIntoOptions(
                $options,
                $input->getOption(self::OPTIONS_KEY_CONFIGFILE)
            );
        } catch (Exception $e) {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) {
                $output->writeln('WARNING: Config file could not be read. Falling back to built-in defaults.');
            }
        }
        $options = $this->mergeEnvironmentVariablesIntoOptions($options);

        // handle the individual options
        // handle the list of images
        $options[self::OPTIONS_KEY_IMAGES] = $this->getArrayOption(
            $input, self::OPTIONS_KEY_IMAGES, $options[self::OPTIONS_KEY_IMAGES]
        );

        // if the user specified a syntax command we assume they want to run
        // the syntax checks
        $syntaxCommand = $input->getOption(self::OPTIONS_KEY_SYNTAXCOMMAND);
        if (!empty($syntaxCommand)) {
            $options[self::OPTIONS_KEY_SYNTAX] = true;
        } else {
            // check for the syntax flag
            $options[self::OPTIONS_KEY_SYNTAX] = $this->getBooleanOption(
                $input, self::OPTIONS_KEY_SYNTAX, $options[self::OPTIONS_KEY_SYNTAX]
            );
        }
        // if they are running syntax, check for the actual command option
        if ($options[self::OPTIONS_KEY_SYNTAX]) {
            $options[self::OPTIONS_KEY_SYNTAXCOMMAND] = $this->getStringOption(
                $input, self::OPTIONS_KEY_SYNTAXCOMMAND, $options[self::OPTIONS_KEY_SYNTAXCOMMAND]
            );
        }

        // if the user specified a unit tests command we assume they want to
        // run the unit tests
        if ($input->hasOption(self::OPTIONS_KEY_UNITTESTSCOMMAND)) {
            $options[self::OPTIONS_KEY_UNITTESTS] = true;
        } else {
            // check for the unit tests flag
            $options[self::OPTIONS_KEY_UNITTESTS] = $this->getBooleanOption(
                $input, self::OPTIONS_KEY_UNITTESTS, $options[self::OPTIONS_KEY_UNITTESTS]
            );
        }
        // if they are running the unit tests, check for the actual command
        if ($options[self::OPTIONS_KEY_UNITTESTS]) {
            $options[self::OPTIONS_KEY_UNITTESTSCOMMAND] = $this->getStringOption(
                $input,
                self::OPTIONS_KEY_UNITTESTSCOMMAND,
                $options[self::OPTIONS_KEY_UNITTESTSCOMMAND]
            );
        }

        $options[self::OPTIONS_KEY_PULL] = $input->getOption(self::OPTIONS_KEY_PULL);

        return $options;
    }
private function getCurrentOptions(InputInterface $input, OutputInterface $output)
    {
        $options = $this->getDefaultOptions();
        try {
            $options = $this->mergeConfigFileIntoOptions(
                $options,
                $input->getOption(self::OPTIONS_KEY_CONFIGFILE)
            );
        } catch (Exception $e) {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) {
                $output->writeln('WARNING: Config file could not be read. Falling back to built-in defaults.');
            }
        }
        $options = $this->mergeEnvironmentVariablesIntoOptions($options);

        // handle the individual options
        // handle the list of images
        $options[self::OPTIONS_KEY_IMAGES] = $this->getArrayOption(
            $input, self::OPTIONS_KEY_IMAGES, $options[self::OPTIONS_KEY_IMAGES]
        );

        // if the user specified a syntax command we assume they want to run
        // the syntax checks
        $syntaxCommand = $input->getOption(self::OPTIONS_KEY_SYNTAXCOMMAND);
        if (!empty($syntaxCommand)) {
            $options[self::OPTIONS_KEY_SYNTAX] = true;
        } else {
            // check for the syntax flag
            $options[self::OPTIONS_KEY_SYNTAX] = $this->getBooleanOption(
                $input, self::OPTIONS_KEY_SYNTAX, $options[self::OPTIONS_KEY_SYNTAX]
            );
        }
        // if they are running syntax, check for the actual command option
        if ($options[self::OPTIONS_KEY_SYNTAX]) {
            $options[self::OPTIONS_KEY_SYNTAXCOMMAND] = $this->getStringOption(
                $input, self::OPTIONS_KEY_SYNTAXCOMMAND, $options[self::OPTIONS_KEY_SYNTAXCOMMAND]
            );
        }

        // if the user specified a unit tests command we assume they want to
        // run the unit tests
        if ($input->hasOption(self::OPTIONS_KEY_UNITTESTSCOMMAND)) {
            $options[self::OPTIONS_KEY_UNITTESTS] = true;
        } else {
            // check for the unit tests flag
            $options[self::OPTIONS_KEY_UNITTESTS] = $this->getBooleanOption(
                $input, self::OPTIONS_KEY_UNITTESTS, $options[self::OPTIONS_KEY_UNITTESTS]
            );
        }
        // if they are running the unit tests, check for the actual command
        if ($options[self::OPTIONS_KEY_UNITTESTS]) {
            $options[self::OPTIONS_KEY_UNITTESTSCOMMAND] = $this->getStringOption(
                $input,
                self::OPTIONS_KEY_UNITTESTSCOMMAND,
                $options[self::OPTIONS_KEY_UNITTESTSCOMMAND]
            );
        }

        $options[self::OPTIONS_KEY_PULL] = $input->getOption(self::OPTIONS_KEY_PULL);

        return $options;
    }
private function getCurrentOptions ( InputInterface $ input , OutputInterface $ output ) { $ options = $ this -> getDefaultOptions ( ) ; try { $ options = $ this -> mergeConfigFileIntoOptions ( $ options , $ input -> getOption ( self :: OPTIONS_KEY_CONFIGFILE ) ) ; } catch ( Exception $ e ) { if ( $ output -> getVerbosity ( ) >= OutputInterface :: VERBOSITY_NORMAL ) { $ output -> writeln ( 'WARNING: Config file could not be read. Falling back to built-in defaults.' ) ; } } $ options = $ this -> mergeEnvironmentVariablesIntoOptions ( $ options ) ; // handle the individual options // handle the list of images $ options [ self :: OPTIONS_KEY_IMAGES ] = $ this -> getArrayOption ( $ input , self :: OPTIONS_KEY_IMAGES , $ options [ self :: OPTIONS_KEY_IMAGES ] ) ; // if the user specified a syntax command we assume they want to run // the syntax checks $ syntaxCommand = $ input -> getOption ( self :: OPTIONS_KEY_SYNTAXCOMMAND ) ; if ( ! empty ( $ syntaxCommand ) ) { $ options [ self :: OPTIONS_KEY_SYNTAX ] = true ; } else { // check for the syntax flag $ options [ self :: OPTIONS_KEY_SYNTAX ] = $ this -> getBooleanOption ( $ input , self :: OPTIONS_KEY_SYNTAX , $ options [ self :: OPTIONS_KEY_SYNTAX ] ) ; } // if they are running syntax, check for the actual command option if ( $ options [ self :: OPTIONS_KEY_SYNTAX ] ) { $ options [ self :: OPTIONS_KEY_SYNTAXCOMMAND ] = $ this -> getStringOption ( $ input , self :: OPTIONS_KEY_SYNTAXCOMMAND , $ options [ self :: OPTIONS_KEY_SYNTAXCOMMAND ] ) ; } // if the user specified a unit tests command we assume they want to // run the unit tests if ( $ input -> hasOption ( self :: OPTIONS_KEY_UNITTESTSCOMMAND ) ) { $ options [ self :: OPTIONS_KEY_UNITTESTS ] = true ; } else { // check for the unit tests flag $ options [ self :: OPTIONS_KEY_UNITTESTS ] = $ this -> getBooleanOption ( $ input , self :: OPTIONS_KEY_UNITTESTS , $ options [ self :: OPTIONS_KEY_UNITTESTS ] ) ; } // if they are running the unit tests, check for the actual command if ( $ options [ self :: OPTIONS_KEY_UNITTESTS ] ) { $ options [ self :: OPTIONS_KEY_UNITTESTSCOMMAND ] = $ this -> getStringOption ( $ input , self :: OPTIONS_KEY_UNITTESTSCOMMAND , $ options [ self :: OPTIONS_KEY_UNITTESTSCOMMAND ] ) ; } $ options [ self :: OPTIONS_KEY_PULL ] = $ input -> getOption ( self :: OPTIONS_KEY_PULL ) ; return $ options ; }
Returns an array of the currently active options given all possible
options, environment variables, config file settings, etc.
@param InputInterface $input The input of options and arguments.
@param OutputInterface $output The output writer.
@return array Returns an array of settings.
Returns an array of the currently active options given all possible options environment variables config file settings etc .