for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Clover to Html package.
*
* (c) Stéphane Demonchaux <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CloverToHtml;
class ConfigDAO
{
* @param string $templatePath
* @param string $key
* @throws \InvalidArgumentException
* @return array
public function findConfig($templatePath, $key = null): array
if (is_file($this->getConfigPath($templatePath)) === false) {
throw new \InvalidArgumentException(
sprintf('Template "%s" with key "%s" not found', $templatePath, $key)
);
}
if ($key === null) {
return [];
$config = $this->loadConfig($templatePath);
if (isset($config[$key])) {
return $config[$key];
* @return string
private function getConfigPath($templatePath): string
return $templatePath.'/config.json';
private function loadConfig($templatePath): array
return json_decode(file_get_contents($this->getConfigPath($templatePath)), true);