for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PhpUnitGen\Configuration;
use PhpUnitGen\Exception\InvalidConfigException;
/**
* Class BaseConfig.
*
* @author Paul Thébaud <[email protected]>.
* @copyright 2017-2018 Paul Thébaud <[email protected]>.
* @license https://opensource.org/licenses/MIT The MIT license.
* @link https://github.com/paul-thebaud/phpunit-generator
* @since Class available since Release 2.0.0.
*/
class BaseConfig implements ConfigInterface
{
* @var array $config The configuration as an array.
protected $config = [];
* ArrayConfig constructor.
* @param mixed $config The config array to use.
public function __construct($config)
$this->validate($config);
$this->config = $config;
}
* Validate a configuration to know if it can be used to construct an instance.
* @param mixed $config The configuration to validate.
* @throws InvalidConfigException If the $config is invalid.
protected function validate($config): void
// Check that $config is an array
if (! is_array($config)) {
throw new InvalidConfigException('The config must be an array.');
// Check boolean parameters
if (! isset($config['interface']) || ! is_bool($config['interface'])) {
throw new InvalidConfigException('"interface" parameter must be set as a boolean.');
* {@inheritdoc}
public function hasInterfaceParsing(): bool
return $this->config['interface'];