path = $this->parse_path($path); if (!$this->exists()) { throw new ErrorException( 'Views directory "'.$this->path.'" not exists.' ); } } private function parse_path($path): string { if (strlen($path) === 0) { $path = './'; } $size = strlen($path); $last = $path[$size - 1]; if ($last !== '/' || $last !== '\\') { return $path.'/'; } return $path; } public function exists(): bool { return is_dir($this->path); } private function get_file_for(string $name): string { $unix = strpos($name, '/'); $dos = strpos($name, '\\'); if ($unix !== false || $dos !== false) { throw new ErrorException('View "'.$name.'" not in views dir.'); } return $this->path.$name; } public function get(string $name): view { return new view($this->get_file_for($name)); } }