PSR12 code standard.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2023-06-08 12:44:59 +00:00
parent afc4a1e3ce
commit d0270b00ca
8 changed files with 108 additions and 116 deletions

View File

@ -1,18 +1,18 @@
<?php
namespace App;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Yaml\Exception\ParseException;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Psr\Log\NullLogger;
/**
* Application class
*
*
* Mostly working as a register pattern for the logging and configuration.
*
*
* @author Jens True <jens.chr.true@gmail.com>
* @license https://opensource.org/licenses/gpl-license.php GNU Public License
* @link https://jcktrue.dks
@ -20,43 +20,43 @@ use Psr\Log\NullLogger;
class App
{
protected Logger $logger;
protected array $config;
protected mixed $config;
/**
* Create a new instance providing a config file
*
*
* @param string $configFile Relative or full path to YML config.
*/
function __construct(string $configFile)
public function __construct(string $configFile)
{
$this->config = Yaml::parseFile($configFile);
$parser = new Yaml();
$this->config = $parser->parseFile($configFile);
$logger = new Logger('app');
if (isset($this->config['log'])) {
$logger->pushHandler(new StreamHandler($this->getConfig()['log']));
}
$logger->info("Initialization complete");
$this->logger = $logger;
}
/**
* Get the full configuration
*
* @return array Full configuration structure
*
* @return mixed Full configuration structure
*/
function getConfig() : array
public function getConfig(): mixed
{
return $this->config;
}
/**
* Get the logger instance.
*
* Get the logger instance.
*
* @return Logger Instance of logger
*/
function getLogger() : Logger
public function getLogger(): Logger
{
return $this->logger;
}
}
}