From 6aed18158b9babbfd292a3e4decbf56fee199164 Mon Sep 17 00:00:00 2001 From: "steve.brazier" Date: Fri, 6 Dec 2013 11:31:39 +0000 Subject: [PATCH] extract the success/failure logging of the builder to an interface. --- PHPCI/BuildLogger.php | 31 +++++++++++++++++++++++++++++++ PHPCI/Builder.php | 2 +- PHPCI/Plugin/Util/Executor.php | 20 ++++++++++---------- 3 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 PHPCI/BuildLogger.php diff --git a/PHPCI/BuildLogger.php b/PHPCI/BuildLogger.php new file mode 100644 index 00000000..ccb6288a --- /dev/null +++ b/PHPCI/BuildLogger.php @@ -0,0 +1,31 @@ + */ -class Builder implements LoggerAwareInterface +class Builder implements LoggerAwareInterface, BuildLogger { /** * @var string diff --git a/PHPCI/Plugin/Util/Executor.php b/PHPCI/Plugin/Util/Executor.php index 99521f57..7ea194eb 100644 --- a/PHPCI/Plugin/Util/Executor.php +++ b/PHPCI/Plugin/Util/Executor.php @@ -2,25 +2,25 @@ namespace PHPCI\Plugin\Util; -use PHPCI\Builder; +use PHPCI\BuildLogger; class Executor { /** - * @var Builder + * @var BuildLogger */ - protected $builder; + protected $logger; /** * @var Factory */ protected $pluginFactory; - function __construct(Factory $pluginFactory, Builder $builder) + function __construct(Factory $pluginFactory, BuildLogger $logger) { $this->pluginFactory = $pluginFactory; - $this->builder = $builder; + $this->logger = $logger; } /** @@ -36,7 +36,7 @@ class Executor } foreach ($config[$stage] as $plugin => $options) { - $this->builder->log('RUNNING PLUGIN: ' . $plugin); + $this->logger->log('RUNNING PLUGIN: ' . $plugin); // Is this plugin allowed to fail? if ($stage == 'test' && !isset($options['allow_failures'])) { @@ -47,7 +47,7 @@ class Executor if ($this->executePlugin($plugin, $options)) { // Execution was successful: - $this->builder->logSuccess('PLUGIN STATUS: SUCCESS!'); + $this->logger->logSuccess('PLUGIN STATUS: SUCCESS!'); } else { @@ -57,7 +57,7 @@ class Executor $this->success = false; } - $this->builder->logFailure('PLUGIN STATUS: FAILED'); + $this->logger->logFailure('PLUGIN STATUS: FAILED'); } } } @@ -80,7 +80,7 @@ class Executor } if (!class_exists($class)) { - $this->builder->logFailure('Plugin does not exist: ' . $plugin); + $this->logger->logFailure('Plugin does not exist: ' . $plugin); return false; } @@ -94,7 +94,7 @@ class Executor $rtn = false; } } catch (\Exception $ex) { - $this->builder->logFailure('EXCEPTION: ' . $ex->getMessage(), $ex); + $this->logger->logFailure('EXCEPTION: ' . $ex->getMessage(), $ex); $rtn = false; }