start = '<stop = '!>>'; $this->attributes = array(); } public function set(string $name, string $content): object { $name = trim($name); $this->attributes[$name] = $content; return $this; } public function render(): string { $parts = explode($this->start, $this->content); $first = array_shift($parts); $results = array(); array_push($results, $first); foreach ($parts as $count) { array_push($results, $this->process_single($count)); } return join("", $results); } public function get_attribute( string $name, ?string $blank = null ): ?string { $name = trim($name); if (array_key_exists($name, $this->attributes)) { return $this->attributes[$name]; } return $blank; } private function process_single(string $count): string { $parts = explode($this->stop, $count); if (count($parts) === 1) { return $this->start.$count; } $name = array_shift($parts); $name = trim($name); $rest = join($this->stop, $parts); $replace = $this->get_attribute($name, ''); return $replace.$rest; } public function __get(string $name): mixed { switch ($name) { case 'start': return $this->start; case 'stop': return $this->stop; } } }