router
1<?php declare(strict_types=1);
2
3namespace Upside\Router;
4
5final readonly class Route
6{
7public string $path;
8/**
9* @var class-string $controller
10*/
11public string $controller;
12public string $action;
13public string $method;
14public string $name;
15public string $pattern;
16
17/**
18* @param class-string $controller
19*/
20public function __construct(string $path, string $controller, string $action, string $method, string $name)
21{
22$this->path = $path;
23$this->controller = $controller;
24$this->action = $action;
25$this->method = $method;
26$this->name = $name;
27
28$this->pattern = \preg_replace_callback(
29'~{[^}]+}~',
30static fn($matches) => '(?<' . \trim($matches[0], '{}') . '>.*)',
31'~' . $this->path . '~'
32);
33}
34}
35