| 1 | <?php |
||
| 5 | class Message |
||
| 6 | { |
||
| 7 | private $message = null; |
||
| 8 | private $test; |
||
| 9 | |||
| 10 | public function __construct(bool $test = false) |
||
| 20 | |||
| 21 | |||
| 22 | public function setMessage($thisMessage) |
||
| 31 | |||
| 32 | |||
| 33 | public function getMessage() |
||
| 34 | { |
||
| 35 | $html = null; |
||
| 36 | // Print messages |
||
| 37 | if ($this->message && $this->message !== '') { |
||
| 38 | $html = '<div id="messagebox">'; |
||
| 39 | foreach ($this->message as $msg) |
||
| 40 | { |
||
| 41 | $html .= ' |
||
| 42 | <div class="message '.htmlentities($msg["type"]).'"> |
||
| 51 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: