src/Psecio/Iniscan/Command/ScanCommand.php
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $path = $input->getOption('path');
        $failOnly = $input->getOption('fail-only');
        $format = $input->getOption('format');
        $context = $input->getOption('context');
        $threshold = $input->getOption('threshold');
        $version = $input->getOption('php');
        $outputPath = $input->getOption('output');

        if ($format === 'html' && $outputPath === null) {
            throw new \InvalidArgumentException('Output path must be set for format "HTML"');
        }

        $context = ($context !== null)
            ? explode(', ', $context) : array();

        // If we're not given a version, assume the current version
        if ($version === null) {
            $version = PHP_VERSION;
        }

        // if we're not given a path at all, try to figure it out
        if ($path === null) {
            $path = php_ini_loaded_file();
        }

        if (!is_file($path)) {
            throw new \Exception('Path is null or not accessible: "'.$path.'"');
        }

        $scan = new \Psecio\Iniscan\Scan($path, $context, $threshold, $version);
        $results = $scan->execute();
        $deprecated = $scan->getMarked();

        $options = array(
            'path' => $path,
            'failOnly' => $failOnly,
            'deprecated' => $deprecated,
            'verbose' => $input->getOption('verbose'),
            'output' => $outputPath
        );

        $format = ($format === null) ? 'console' : $format;
        $formatClass = "\\Psecio\\Iniscan\\Command\\ScanCommand\\Output\\".ucwords(strtolower($format));
        if (!class_exists($formatClass)) {
            throw new \Psecio\Iniscan\Exceptions\FormatNotFoundException('Output format "'.$format.'" not found');
        }
        $outputHandler = new $formatClass($output, $options);
        return $outputHandler->render($results);
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $path = $input->getOption('path');
        $failOnly = $input->getOption('fail-only');
        $format = $input->getOption('format');
        $context = $input->getOption('context');
        $threshold = $input->getOption('threshold');
        $version = $input->getOption('php');
        $outputPath = $input->getOption('output');

        if ($format === 'html' && $outputPath === null) {
            throw new \InvalidArgumentException('Output path must be set for format "HTML"');
        }

        $context = ($context !== null)
            ? explode(', ', $context) : array();

        // If we're not given a version, assume the current version
        if ($version === null) {
            $version = PHP_VERSION;
        }

        // if we're not given a path at all, try to figure it out
        if ($path === null) {
            $path = php_ini_loaded_file();
        }

        if (!is_file($path)) {
            throw new \Exception('Path is null or not accessible: "'.$path.'"');
        }

        $scan = new \Psecio\Iniscan\Scan($path, $context, $threshold, $version);
        $results = $scan->execute();
        $deprecated = $scan->getMarked();

        $options = array(
            'path' => $path,
            'failOnly' => $failOnly,
            'deprecated' => $deprecated,
            'verbose' => $input->getOption('verbose'),
            'output' => $outputPath
        );

        $format = ($format === null) ? 'console' : $format;
        $formatClass = "\\Psecio\\Iniscan\\Command\\ScanCommand\\Output\\".ucwords(strtolower($format));
        if (!class_exists($formatClass)) {
            throw new \Psecio\Iniscan\Exceptions\FormatNotFoundException('Output format "'.$format.'" not found');
        }
        $outputHandler = new $formatClass($output, $options);
        return $outputHandler->render($results);
    }
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ path = $ input -> getOption ( 'path' ) ; $ failOnly = $ input -> getOption ( 'fail-only' ) ; $ format = $ input -> getOption ( 'format' ) ; $ context = $ input -> getOption ( 'context' ) ; $ threshold = $ input -> getOption ( 'threshold' ) ; $ version = $ input -> getOption ( 'php' ) ; $ outputPath = $ input -> getOption ( 'output' ) ; if ( $ format === 'html' && $ outputPath === null ) { throw new \ InvalidArgumentException ( 'Output path must be set for format "HTML"' ) ; } $ context = ( $ context !== null ) ? explode ( ', ' , $ context ) : array ( ) ; // If we're not given a version, assume the current version if ( $ version === null ) { $ version = PHP_VERSION ; } // if we're not given a path at all, try to figure it out if ( $ path === null ) { $ path = php_ini_loaded_file ( ) ; } if ( ! is_file ( $ path ) ) { throw new \ Exception ( 'Path is null or not accessible: "' . $ path . '"' ) ; } $ scan = new \ Psecio \ Iniscan \ Scan ( $ path , $ context , $ threshold , $ version ) ; $ results = $ scan -> execute ( ) ; $ deprecated = $ scan -> getMarked ( ) ; $ options = array ( 'path' => $ path , 'failOnly' => $ failOnly , 'deprecated' => $ deprecated , 'verbose' => $ input -> getOption ( 'verbose' ) , 'output' => $ outputPath ) ; $ format = ( $ format === null ) ? 'console' : $ format ; $ formatClass = "\\Psecio\\Iniscan\\Command\\ScanCommand\\Output\\" . ucwords ( strtolower ( $ format ) ) ; if ( ! class_exists ( $ formatClass ) ) { throw new \ Psecio \ Iniscan \ Exceptions \ FormatNotFoundException ( 'Output format "' . $ format . '" not found' ) ; } $ outputHandler = new $ formatClass ( $ output , $ options ) ; return $ outputHandler -> render ( $ results ) ; }
Execute the "scan" command

@param  InputInterface $input Input object
@param  OutputInterface $output Output object
@throws \Psecio\Iniscan\Exceptions\FormatNotFoundException
@throws \Exception
@return null
Execute the scan command