mirror of
https://github.com/igorsimdyanov/php8.git
synced 2025-08-03 16:43:03 +00:00
27 lines
558 B
PHP
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;
|
|
}
|
|
}
|