properties['date'] ?? null; if (empty($date_str)) { throw new \Exception('Article ' . $title . ' has no date property'); } $this->date_formatted = date(self::DATE_FORMAT, strtotime($date_str)); } public function render(string $tpl_path) { $template = file_get_contents($tpl_path); $template = str_replace('%TITLE%', $this->title, $template); $template = str_replace('%CONTENT%', $this->content, $template); $template = str_replace('%DATE_FORMATTED%', $this->date_formatted, $template); return $template; } }