Files
php_8/redis/mvc/controllers/router.php
2022-07-10 16:02:35 +03:00

27 lines
558 B
PHP

<?php
namespace MVC\Controllers;
class Router
{
public string $model;
public ?string $ext;
public ?int $id;
public static function parse(string $path) : Router
{
list($path, $ext) = explode('.', $path);
$arr = explode('/', $path);
return new self($arr[0], $ext, count($arr) > 1 ? $arr[1] : null);
}
private function __construct(
string $model,
?string $ext = null,
?int $id = null)
{
$this->model = $model;
$this->ext = $ext;
$this->id = $id;
}
}