for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Alxarafe. Development of PHP applications in a flash!
* Copyright (C) 2018-2020 Alxarafe <[email protected]>
*/
namespace Alxarafe\Core\Singletons;
use DateTimeZone;
use Exception;
use Monolog\Handler\FirePHPHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Logger as MonologLogger;
* Class Logger
*
* @package Alxarafe\Core\Providers
abstract class Logger
{
* The logger.
* @var MonologLogger
private static MonologLogger $logger;
* Logger constructor.
public static function load(string $index = 'main')
$index
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public static function load(/** @scrutinizer ignore-unused */ string $index = 'main')
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
self::$logger = new MonologLogger('core_logger');
set_exception_handler(['static', 'exceptionHandler']);
try {
$timeZone = RegionalInfo::$config['timezone'];
self::$logger->setTimezone(
new DateTimeZone($timeZone)
);
self::$logger->pushHandler(new StreamHandler(CONFIGURATION_DIR . '/core.log', MonologLogger::DEBUG));
} catch (Exception $e) {
dump($e);
}
self::$logger->pushHandler(new FirePHPHandler());
* Catch the exception handler and adds to logger.
* @param Exception $e
public static function exceptionHandler($e): void
FlashMessages::setError($e->getMessage());
self::$logger->error(
'Exception [' . $e->getCode() . ']: ' . $e->getMessage() . PHP_EOL
. $e->getFile() . ':' . $e->getLine() . PHP_EOL
. $e->getTraceAsString()
* Returns the logger.
* @return MonologLogger
public static function getLogger(): MonologLogger
return self::$logger;
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.