exists()) { throw new ErrorException('View "'.$path.'" not exists.'); } } public function exists(): bool { return is_file($this->path); } private function read(): string { $file = fopen($this->path, 'r'); $size = filesize($this->path); if ($file === false) { throw new ErrorException('View "'.$path.'" is not readable.'); } $content = fread($file, $size); fclose($file); return $content; } public function rendering(): renderer { static $content = null; if ($content === null) { $content = $this->read(); } return new renderer($content); } }