Cronario\AbstractWorker::loadConfigFile PHP Method

loadConfigFile() protected static method

protected static loadConfigFile ( $path ) : mixed | string
$path
return mixed | string
    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;
    }