From 6f4cd9178ba55ffb3fd80816cf9f4cda39ee0cad Mon Sep 17 00:00:00 2001 From: Fbenas Date: Sun, 12 Mar 2017 17:46:18 +0000 Subject: Doc block and PSR --- src/Message/Handler.php | 72 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 8 deletions(-) (limited to 'src/Message/Handler.php') diff --git a/src/Message/Handler.php b/src/Message/Handler.php index 89752c5..825ceda 100644 --- a/src/Message/Handler.php +++ b/src/Message/Handler.php @@ -6,25 +6,52 @@ use App\Message\Overview; /** * Handles messages and context +* +* @author Phil Burton */ class Handler { + /** + * The important set of injects for this handler + * + * @var string[] + */ protected $important = []; + /** + * The important set of values of injects for this handler + * + * @var mixed[] + */ protected $importantValues = []; + /** + * Construct our handler + * + * @author Phil Burton + * @param string[] $important + */ public function __construct($important) { $this->setupImportant($important); } /** - * Set's up important attributes on this class + * Set the important list + * + * @author Phil Burton + * @param string[] $important */ public function setupImportant($important = []) { $this->important = $important; } + /** + * Set important values + * + * @author Phil Burton + * @param mixed[] $array + */ protected function setImportantValues($array) { foreach ($array as $name => $value) { @@ -32,6 +59,13 @@ class Handler } } + /** + * Add an important value to our array + * + * @author Phil Burton + * @param string $name + * @param mixed[] $value + */ protected function addImportantValue($name, $value) { if (in_array($name, $this->important)) { @@ -41,15 +75,31 @@ class Handler return $name; } + /** + * Get a single important value + * + * @author Phil Burton + * @param string $name + * @return mixed + */ public function returnImportant($name) { if (!array_key_exists($name, $this->importantValues)) { throw new \Exception('The var ' . $name . ' is not set in this context'); } - + return $this->importantValues[$name]; } + /** + * Magic __call override to be able to get improtant values using getMyImportant() + * which then runs $this->returnImportant('myImportant') + * + * @author Phil Burton + * @param string $name + * @param mixed[] $arguments + * @return string + */ public function __call($name, $arguments) { if (strpos($name, 'get') === 0) { @@ -57,16 +107,22 @@ class Handler } } + /** + * Render the opening message + * + * @author Phil Burton + * @return string + */ public function renderOpeningMessage() { - $overview = new Overview(); + $overview = new Overview(); - $overview->setFromArray($this->importantValues); + $overview->setFromArray($this->importantValues); - $message = $overview->renderMessage(); + $message = $overview->renderMessage(); - $this->setImportantValues($overview->getImportantValues()); + $this->setImportantValues($overview->getImportantValues()); - return $message; + return $message; } -} \ No newline at end of file +} -- cgit v1.2.3