for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @copyright 2018 Aleksander Stelmaczonek <[email protected]>
* @license MIT License, see license file distributed with this source code
*/
namespace Koriit\PHPDeps\Config;
use Koriit\PHPDeps\Config\Exceptions\InvalidConfig;
class ConfigValidator
{
* @param Config $config
*
* @throws InvalidConfig
public function check(Config $config)
$this->checkIfEmpty($config);
$this->checkNameDuplication($config);
}
private function checkIfEmpty(Config $config)
if (empty($config->getModules()) && empty($config->getModuleDetectors())) {
throw new InvalidConfig('Configuration cannot be empty');
private function checkNameDuplication(Config $config)
$modules = [];
foreach ($config->getModules() as $module) {
$modules[] = $module->getName();
if (\count($modules) != \count(\array_unique($modules))) {
throw new InvalidConfig('Two or more of your configured modules have the same name');