protected static function loadConfigFile($path)
{
if (!is_file($path)) {
throw new Exception\WorkerException("Configuration file not exist '{$path}'");
}
$extension = pathinfo($path, PATHINFO_EXTENSION);
if ('php' === $extension) {
$config = (require_once $path);
} elseif ('json' === $extension) {
$config = file_get_contents($path);
$config = json_decode($config, true);
} else {
throw new Exception\WorkerException("Configuration file must be PHP or JSON : '{$path}'");
}
if (!is_array($config)) {
throw new Exception\WorkerException("Configuration file must return array inside '{$path}'");
}
return $config;
}