Check configuration
@return void

@throws InvalidArgumentException
506393
protected function checkConfiguration()
    {
        if (
            empty($this->config['name'])
            || empty($this->config['username'])
            || empty($this->config['host'])
        ) {
            throw new InvalidArgumentException(static::E_CONFIG);
        }
    }
1182545
private function checkConnect(): void
    {
        if (empty($this->connect['type']) ||
            empty($this->connect['host']) ||
            empty($this->connect['name']) ||
            empty($this->connect['user'])
        ) {
            throw new ConfigurationException(
                'Database adapter is not configured.
                Please check `db` configuration section: required type, host, db name and user'
            );
        }
    }
81917
public function validate()
    {
        if (!$this->migrationsDatabaseName) {
            $message = 'Migrations Database Name must be configured in order to use AntiMattr migrations.';
            throw new ConfigurationValidationException($message);
        }
        if (!$this->migrationsNamespace) {
            $message = 'Migrations namespace must be configured in order to use AntiMattr migrations.';
            throw new ConfigurationValidationException($message);
        }
        if (!$this->migrationsDirectory) {
            $message = 'Migrations directory must be configured in order to use AntiMattr migrations.';
            throw new ConfigurationValidationException($message);
        }
    }
331466
public function init()
    {
        $extensions = [];

        if (empty($this->extensionClasses) && empty($this->userConfig)) {
            return;
        }

        foreach ($this->extensionClasses as $extensionClass) {
            if (!class_exists($extensionClass)) {
                throw new \InvalidArgumentException(sprintf(
                    'Extension class "%s" does not exist',
                    $extensionClass
                ));
            }

            $extension = new $extensionClass();

            if (!$extension instanceof ExtensionInterface) {
                throw new \InvalidArgumentException(sprintf(
                    // add any manually specified extensions
                    'Extension "%s" must implement the PhpBench\\Extension interface',
                    get_class($extension)
                ));
            }

            $extensions[] = $extension;

            $this->config = array_merge(
                $this->config,
                $extension->getDefaultConfig()
            );
        }

        $diff = array_diff(array_keys($this->userConfig), array_keys($this->config));

        if ($diff) {
            throw new \InvalidArgumentException(sprintf(
                'Unknown configuration keys: "%s". Permitted keys: "%s"',
                implode('", "', $diff), implode('", "', array_keys($this->config))
            ));
        }

        $this->config = array_merge(
            $this->config,
            $this->userConfig
        );

        foreach ($extensions as $extension) {
            $extension->load($this);
        }
    }
392497
private function checkProperties()
    {
        if (!isset($this->listId)) {
            throw new \Exception('[listId] is not set', 1);
        }

        if (!isset($this->installationUrl)) {
            throw new \Exception('[installationUrl] is not set', 1);
        }

        if (!isset($this->apiKey)) {
            throw new \Exception('[apiKey] is not set', 1);
        }
    }
331964
protected function initAllConfigs()
    {
        if ($this->isInitialized) {
            return;
        }

        $this->logger->info('Checking and initializing config files');
        foreach ($this->getEnvironments() as $environment) {
            $this->initConfig($environment);
        }

        $this->isInitialized = true;
    }
297196
public function verifyConfig()
    {
        $keys = ['implementedFinders', 'implementedMethods'];
        foreach ($keys as $key) {
            if (!isset($this->_config[$key])) {
                continue;
            }

            foreach ($this->_config[$key] as $method) {
                if (!is_callable([$this, $method])) {
                    throw new Exception(sprintf('The method %s is not callable on class %s', $method, get_class($this)));
                }
            }
        }
    }
1360026
private function verifyConfig()
    {
        foreach (Config::KEYS as $key) {
            if (!isset(Config::get()[$key])) {
                throw new OrmException('Key "'.$key.'" is not given.');
            }
        }
    }
788480
protected function validateConfig()
    {
        $this->validateUrls();
        $this->validateRefreshInterval();
        $this->validateCacheFile();
        $this->validateFilePath();
        $this->validateParser();

        return true;
    }
1207797
private function parseConfiguration(): void
    {
        $configFilePath = dirname(__DIR__, 7) . '/src/' . $this->getConfigPath() . '/config.ini';

        if (!file_exists($configFilePath)) {
            throw new ConfigurationNotFoundException('Configuration file in ' . $configFilePath . ' not found.');
        }

        $this->configuration = parse_ini_file($configFilePath, true);

        if (!$this->isConfigured(['root_namespace', 'env'], 'framework')) {
            throw new MissingConfigurationException(['root_namespace', 'env'], 'framework');
        }
    }
1194352
public function process()
    {
        // Find files
        $files = $this->finder->find();
        if (0 === count($files)) {
            throw new \InvalidArgumentException('No files found for format: *.' . $this->getFormat());
        }

        foreach ($files as $file) {
            $valuesSet = 0;
            $configurations = $this->getConfigurationsFromFile($file);
            foreach ($configurations as $configPath => $configValues) {
                $scopeConfigValues = $this->transformConfigToScopeConfig($configPath, $configValues);
                foreach ($scopeConfigValues as $scopeConfigValue) {
                    $this->configWriter->save(
                        $configPath,
                        $scopeConfigValue['value'],
                        $scopeConfigValue['scope'],
                        $this->scopeConverter->convert($scopeConfigValue['scope_id'], $scopeConfigValue['scope'])
                    );

                    $this->getOutput()->writeln(sprintf('<comment>%s => %s</comment>', $configPath, $scopeConfigValue['value']));
                    $valuesSet++;
                }
            }

            $this->getOutput()->writeln(sprintf('<info>Processed: %s with %s value(s).</info>', $file, $valuesSet));
        }
    }
348581
public function detectConfiguration()
	{
		// Use default file readers if none provided
		if (empty($this->file_readers)) {
			$this->file_readers = [
				JsonReader::class => new JsonReader(),
				GraphMLReader::class => new GraphMLReader(),
				BpmnReader::class => new BpmnReader(),
			];
		}

		// Scan base dir for machines and find youngest file
		if ($this->file_list === null) {
			$dh = opendir($this->base_dir);
			if (!$dh) {
				throw new RuntimeException('Cannot open base dir: ' . $this->base_dir);
			}
			$this->file_list = [];
			while (($file = readdir($dh)) !== false) {
				if ($file[0] != '.') {
					$this->file_list[] = $file;
				}
			}
			closedir($dh);
		}
	}
1221059
protected function configureProtocol(): void
    {
        $protocol = $this->options['protocol'];

        if (!$protocol || !($protocol instanceof Protocol)) {
            throw new InvalidArgumentException('Invalid protocol option');
        }

        $this->protocol = $protocol;
    }
515753
public function checkDirectory(): bool
    {
        if (empty($this->directory)) {
            throw new InvalidConfigException(
                "Log directory is not defined in given configuration, ".
                "define it using 'query_log_directory' key to activate logging.");
        }

        // provide some performance escaping to call "is_dir" and "mkdir" functions
        self::$directoryChecked = self::$directoryChecked ?: is_dir($this->directory);
        if (!self::$directoryChecked) {
            self::$directoryChecked = mkdir($this->directory, 0644, true);

            // !!! notice !!!
            // set your log dir secure
            file_put_contents($this->directory .'/index.php',
                "<?php header('HTTP/1.1 403 Forbidden'); ?>");
            // this action is for only apache, see nginx configuration here:
            // http://nginx.org/en/docs/http/ngx_http_access_module.html
            file_put_contents($this->directory .'/.htaccess',
                "Order deny,allow\r\nDeny from all");
        }

        return self::$directoryChecked;
    }
1275423
public static function initialize(Configuration $configuration)
    {
        $configuration = static::normalizeConfiguration($configuration);
        
        if (!$configuration->validateIdentity()) {
            throw new InvalidArgumentException('Bad configuration identity');
        }
        
        if (!$configuration->validateConnection()) {
            throw new InvalidArgumentException('Bad connection settings. Check your configuration file ":file"', [
                'file' => $configuration->getIdentity(),
            ]);
        }
        
        static::loadAdditionalConfiguration($configuration);
        
        static::getServiceContainer()->set('configuration', $configuration);
        static::getServiceContainer()->set('classLoader', self::initializeClassLoader());
        
        static::getServiceContainer()->getDispatcher()
            ->addListener(null, [static::getServiceContainer()->getLogger(), 'event']);
    }
1293242
public function checkTypeExists(array &$options)
    {
        //if an improper value was supplied
        if (!array_key_exists($options['type'], $this->fieldTypes)) {
            throw new \InvalidArgumentException('The '.$options['type'].' field type in your '.$this->config->getOption('name').' configuration file is not valid');
        }

        //if this is a settings page and a field was supplied that is excluded
        if ($this->config->getType() === 'settings' && in_array($options['type'], $this->settingsFieldExclusions)) {
            throw new \InvalidArgumentException('The '.$options['type'].' field in your '.
                            $this->config->getOption('name').' settings page cannot be used on a settings page');
        }
    }
819557
protected function isProperlyConfigured()
    {
        if (isset($this->isProperlyConfigured)) {
            return $this->isProperlyConfigured;
        }

        return $this->isProperlyConfigured = $this->checkConfiguration();
    }