mirror of
https://github.com/igorsimdyanov/php8.git
synced 2025-07-29 12:52:43 +00:00
18 lines
388 B
PHP
18 lines
388 B
PHP
<?php
|
|
namespace Factory;
|
|
|
|
abstract class Router
|
|
{
|
|
public static function parse(string $url) : mixed
|
|
{
|
|
$arr = explode('/', $url);
|
|
$class = 'Factory\\Models\\' . ucfirst($arr[0]);
|
|
$id = count($arr) > 1 ? $arr[1] : null;
|
|
$obj = new $class();
|
|
|
|
return is_null($id) ? $obj : $obj->collection[$id];
|
|
}
|
|
|
|
abstract public function render();
|
|
}
|