setupImportant($important); } /** * Set's up important attributes on this class */ public function setupImportant($important = []) { $this->important = $important; } protected function setImportantValues($array) { foreach ($array as $name => $value) { $this->addImportantValue($name, $value); } } protected function addImportantValue($name, $value) { if (in_array($name, $this->important)) { $this->importantValues[$name] = $value; } return $name; } 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]; } public function __call($name, $arguments) { if (strpos($name, 'get') === 0) { $this->returnImporant(substr($name, 3)); } } public function renderOpeningMessage() { $overview = new Overview(); $overview->setFromArray($this->importantValues); $message = $overview->renderMessage(); $this->setImportantValues($overview->getImportantValues()); return $message; } }