for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of PhpUnitGen.
*
* (c) 2017-2018 Paul Thébaud <[email protected]>
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace PhpUnitGen\Configuration;
use PhpUnitGen\Exception\InvalidConfigException;
use PhpUnitGen\Exception\JsonException;
use PhpUnitGen\Util\Json;
* Class JsonConsoleConfigFactory.
* @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 JsonConsoleConfigFactory extends AbstractConsoleConfigFactory
{
* {@inheritdoc}
protected function decode(string $configPath): array
try {
$configArray = Json::decode(file_get_contents($configPath));
} catch (JsonException $exception) {
throw new InvalidConfigException('Unable to parse JSON config');
}
if (! is_array($configArray)) {
throw new InvalidConfigException('Invalid JSON config');
return $configArray;