Peridot\Console\ConfigurationReader::read PHP Method

read() public method

Read configuration information from input
public read ( ) : Configuration
return Peridot\Configuration
    public function read()
    {
        $configuration = new Configuration();
        $options = ['grep' => [$configuration, 'setGrep'], 'no-colors' => [$configuration, 'disableColors'], 'force-colors' => [$configuration, 'enableColorsExplicit'], 'bail' => [$configuration, 'stopOnFailure'], 'configuration' => [$configuration, 'setConfigurationFile']];
        if ($path = $this->input->getArgument('path')) {
            $configuration->setPath($path);
        }
        foreach ($options as $option => $callable) {
            $this->callForOption($option, $callable);
        }
        return $configuration;
    }

Usage Example

            assert(!$config->areColorsEnabled(), "colors should be disabled");
            assert($config->shouldStopOnFailure(), "should stop on failure");
            assert($config->getConfigurationFile() == __FILE__, "config should be current file");
        };
    });
    describe("->read()", function () {
        it("should return configuration from InputInterface", function () {
            $reader = new ConfigurationReader($this->input);
            $config = $reader->read();
            call_user_func($this->assert, $config);
        });
        it("should throw an exception if configuration is specified but does not exist", function () {
            $this->definition['--configuration'] = '/path/to/nope.php';
            $input = new ArrayInput($this->definition, new InputDefinition());
            $reader = new ConfigurationReader($input);
            $exception = null;
            try {
                $reader->read();
            } catch (\RuntimeException $e) {
                $exception = $e;
            }
            assert(!is_null($exception), "exception should not be null");
        });
    });
    describe('::readInput()', function () {
        it('should read input', function () {
            $config = ConfigurationReader::readInput($this->input);
            call_user_func($this->assert, $config);
        });
    });
});