fixed a typo
This commit is contained in:
parent
cbbfe45c1b
commit
d19e7d5b25
|
@ -1,4 +1,11 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) 2022. Micha Espey <tracer@24unix.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
|
@ -11,23 +18,21 @@ class Config
|
|||
{
|
||||
private array $config;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Check for either config.json.local or config.json.
|
||||
$configFile = dirname(path: __DIR__, levels: 2) . "/config.json.local";
|
||||
if (!file_exists(filename: $configFile)) {
|
||||
$configFile = dirname(path: __DIR__, levels: 2) . "/config.json";
|
||||
}
|
||||
|
||||
if (!file_exists(filename: $configFile)) {
|
||||
throw new Exception(message: 'Missing config file');
|
||||
die('Missing config file');
|
||||
}
|
||||
$configJSON = file_get_contents(filename: $configFile);
|
||||
|
||||
if (json_decode(json: $configJSON) === null) {
|
||||
throw new Exception(message: 'Config file is not valid JSON.');
|
||||
die('Config file is not valid JSON.');
|
||||
}
|
||||
|
||||
$this->config = json_decode(json: $configJSON, associative: true);
|
||||
|
|
Loading…
Reference in New Issue