Implemented all changes as proposed by the inspection report.

This commit is contained in:
Abel Hoogeveen 2019-01-21 20:44:53 +01:00
parent e10d84b65d
commit d670e9676b
No known key found for this signature in database
GPG Key ID: 96C2234920BF4292
17 changed files with 21 additions and 25 deletions

View File

@ -364,6 +364,7 @@ class Configurator
foreach ($deferredComponentClasses as $deferredComponentClass) foreach ($deferredComponentClasses as $deferredComponentClass)
{ {
Logger::logDebug("Invoking '" . $deferredComponentClass->method . "' on component '" . $deferredComponentClass->componentClass . "'"); Logger::logDebug("Invoking '" . $deferredComponentClass->method . "' on component '" . $deferredComponentClass->componentClass . "'");
/** @var DeferredComponentClass $deferredComponentClass */
$deferredComponentClass->invoke(call_user_func_array( $deferredComponentClass->invoke(call_user_func_array(
array($container->{$deferredComponentClass->componentClass}, $deferredComponentClass->method), array($container->{$deferredComponentClass->componentClass}, $deferredComponentClass->method),
$deferredComponentClass->arguments $deferredComponentClass->arguments

View File

@ -35,8 +35,8 @@
*/ */
namespace FuzeWorks; namespace FuzeWorks;
use FuzeWorks\Exception\Exception;
use FuzeWorks\Exception\CoreException; use FuzeWorks\Exception\EventException;
/** /**
* FuzeWorks Core. * FuzeWorks Core.
@ -109,6 +109,7 @@ class Core
* Stop FuzeWorks and run all shutdown functions. * Stop FuzeWorks and run all shutdown functions.
* *
* Afterwards run the Logger shutdown function in order to possibly display the log * Afterwards run the Logger shutdown function in order to possibly display the log
* @throws EventException
*/ */
public static function shutdown() public static function shutdown()
{ {

View File

@ -47,4 +47,3 @@ class NotifierEvent extends Event
{ {
} }
?>

View File

@ -86,4 +86,3 @@ class PluginGetEvent extends Event
} }
} }
?>

View File

@ -46,4 +46,3 @@ class ConfigException extends Exception
{ {
} }
?>

View File

@ -46,4 +46,3 @@ class ConfiguratorException extends Exception
{ {
} }
?>

View File

@ -46,4 +46,3 @@ class CoreException extends Exception
{ {
} }
?>

View File

@ -46,4 +46,3 @@ class EventException extends Exception
{ {
} }
?>

View File

@ -46,4 +46,3 @@ class FactoryException extends Exception
{ {
} }
?>

View File

@ -46,4 +46,3 @@ class HelperException extends Exception
{ {
} }
?>

View File

@ -46,4 +46,3 @@ class InvalidArgumentException extends Exception
{ {
} }
?>

View File

@ -46,4 +46,3 @@ class LibraryException extends Exception
{ {
} }
?>

View File

@ -46,4 +46,3 @@ class LoggerException extends Exception
{ {
} }
?>

View File

@ -46,4 +46,3 @@ class PluginException extends Exception
{ {
} }
?>

View File

@ -121,9 +121,10 @@ class Factory
*/ */
public $plugins; public $plugins;
/** /**
* Factory instance constructor. Should only really be called once * Factory instance constructor. Should only really be called once
*/ * @throws ConfigException
*/
public function __construct() public function __construct()
{ {
// If there is no sharedFactoryInstance, prepare it // If there is no sharedFactoryInstance, prepare it

View File

@ -36,6 +36,7 @@
namespace FuzeWorks; namespace FuzeWorks;
use FuzeWorks\Exception\ConfigException;
use FuzeWorks\Exception\EventException; use FuzeWorks\Exception\EventException;
use FuzeWorks\Exception\Exception; use FuzeWorks\Exception\Exception;
@ -104,6 +105,7 @@ class Logger {
* Initiates the Logger. * Initiates the Logger.
* *
* Registers the error and exception handler, when required to do so by configuration * Registers the error and exception handler, when required to do so by configuration
* @throws ConfigException
*/ */
public function __construct() public function __construct()
{ {
@ -119,15 +121,15 @@ class Logger {
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
// Set PHP error reporting // Set PHP error reporting
if ($cfg_error->php_error_reporting) if ($cfg_error->get('php_error_reporting'))
error_reporting(true); error_reporting(true);
else else
error_reporting(false); error_reporting(false);
// Set the environment variables // Set the environment variables
self::$log_last_request = $cfg_error->log_last_request_to_file; self::$log_last_request = $cfg_error->get('log_last_request_to_file');
self::$log_errors_to_file = $cfg_error->log_errors_to_file; self::$log_errors_to_file = $cfg_error->get('log_errors_to_file');
self::$logger_template = $cfg_error->logger_template; self::$logger_template = $cfg_error->get('logger_template');
self::newLevel('Logger Initiated'); self::newLevel('Logger Initiated');
} }
@ -185,6 +187,7 @@ class Logger {
* @codeCoverageIgnore * @codeCoverageIgnore
* *
* Logs data to screen when requested to do so * Logs data to screen when requested to do so
* @throws EventException
*/ */
public static function shutdown() public static function shutdown()
{ {
@ -289,6 +292,7 @@ class Logger {
/** /**
* Output the entire log to the screen. Used for debugging problems with your code. * Output the entire log to the screen. Used for debugging problems with your code.
* @codeCoverageIgnore * @codeCoverageIgnore
* @throws EventException
*/ */
public static function logToScreen() public static function logToScreen()
{ {

View File

@ -37,6 +37,7 @@
namespace FuzeWorks; namespace FuzeWorks;
use FuzeWorks\ConfigORM\ConfigORM; use FuzeWorks\ConfigORM\ConfigORM;
use FuzeWorks\Event\PluginGetEvent; use FuzeWorks\Event\PluginGetEvent;
use FuzeWorks\Exception\ConfigException;
use FuzeWorks\Exception\PluginException; use FuzeWorks\Exception\PluginException;
use ReflectionClass; use ReflectionClass;
use ReflectionException; use ReflectionException;
@ -90,12 +91,12 @@ class Plugins
/** /**
* Called upon creation of the plugins class. * Called upon creation of the plugins class.
* *
* @return void * @throws ConfigException
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function __construct() public function __construct()
{ {
$this->cfg = Factory::getInstance()->config->plugins; $this->cfg = Factory::getInstance()->config->getConfig('plugins');
} }
/** /**
@ -169,7 +170,7 @@ class Plugins
$pluginName = ucfirst($header->getName()); $pluginName = ucfirst($header->getName());
// Check if the plugin is disabled // Check if the plugin is disabled
if (in_array($pluginName, $this->cfg->disabled_plugins)) if (in_array($pluginName, $this->cfg->get('disabled_plugins')))
{ {
$this->headers[$pluginName] = 'disabled'; $this->headers[$pluginName] = 'disabled';
return false; return false;
@ -245,7 +246,7 @@ class Plugins
} }
// If disabled, don't bother // If disabled, don't bother
if (in_array($pluginName, $this->cfg->disabled_plugins)) if (in_array($pluginName, $this->cfg->get('disabled_plugins')))
{ {
throw new PluginException("Could not load plugin. Plugin is disabled", 1); throw new PluginException("Could not load plugin. Plugin is disabled", 1);
} }