From 0d670bba947d825e5cc2a3a89683449b852288f3 Mon Sep 17 00:00:00 2001 From: nashe Date: Fri, 7 Jul 2017 23:49:51 +0100 Subject: Make PlanetError more testable --- app/classes/PlanetError.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/app/classes/PlanetError.php b/app/classes/PlanetError.php index 31923a3..e47ab1d 100644 --- a/app/classes/PlanetError.php +++ b/app/classes/PlanetError.php @@ -3,21 +3,30 @@ class PlanetError { public $level; + public $levels = array( + 1 => 'notice', + 2 => 'warning', + 3 => 'error', + ); public $message; + /** + * PlanetError constructor. + * @param $level + * @param $message + */ public function __construct($level, $message) { $this->level = (int) $level; $this->message = $message; } - public function toString($format = '%1$s : %2$s') + /** + * @param string $format + * @return string + */ + public function toString($format = '%1$s: %2$s') { - $levels = array( - 1 => 'notice', - 2 => 'warning', - 3 => 'error', - ); - return sprintf($format, $levels[$this->level], $this->message); + return sprintf($format, $this->levels[$this->level], $this->message); } } -- cgit v1.2.1