| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | <?phpnamespace la_restaurant_theme;require_once('view.php');class views {    private string $path;    public function __construct(string $path) {        $this->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));    }}
 |