for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PhpUnitGen\Configuration;
use PhpUnitGen\Exception\InvalidConfigException;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
/**
* Class YamlConsoleConfigFactory.
*
* @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 YamlConsoleConfigFactory implements ConsoleConfigFactoryInterface
{
* {@inheritdoc}
public function invoke(string $configPath): ConsoleConfigInterface
try {
$configArray = Yaml::parse(file_get_contents($configPath));
} catch (ParseException $exception) {
throw new InvalidConfigException(sprintf(
'Unable to parse YAML config: %s',
$exception->getMessage()
));
}
return new ConsoleConfig($configArray);