Liip\RMT\Prerequisite\ComposerStabilityCheck::execute PHP Method

execute() public method

public execute ( )
    public function execute()
    {
        // Handle the skip option
        if (Context::get('information-collector')->getValueFor(self::SKIP_OPTION)) {
            Context::get('output')->writeln('<error>composer minimum-stability check skipped</error>');
            return;
        }
        // file exists?
        if (!file_exists('composer.json')) {
            Context::get('output')->writeln('<error>composer.json does not exist, skipping check</error>');
            return;
        }
        // if file is not readable, we can't perform our check
        if (!is_readable('composer.json')) {
            throw new \Exception('composer.json can not be read (permissions?), (you can force a release with option --' . self::SKIP_OPTION . ')');
        }
        $contents = json_decode(file_get_contents('composer.json'), true);
        // fail if the composer config falls back to default, and this check has something else but default set
        if (!isset($contents['minimum-stability']) && $this->options['stability'] != 'stable') {
            throw new \Exception('minimum-stability is not set, but RMT config requires: ' . $this->options['stability'] . ' (you can force a release with option --' . self::SKIP_OPTION . ')');
        }
        // fail if stability is set and not the one expected
        if (isset($contents['minimum-stability']) && $contents['minimum-stability'] != $this->options['stability']) {
            throw new \Exception('minimum-stability is set to: ' . $contents['minimum-stability'] . ', but RMT config requires: ' . $this->options['stability'] . ' (you can force a release with option --' . self::SKIP_OPTION . ')');
        }
        $this->confirmSuccess();
    }