blob: 5b4930df2665312b2902b9f44a7ecd880bdf8c4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php
declare(strict_types=1);
namespace Lightscale\Router;
use Closure;
use Lightscale\Router\Enums\HttpMethod;
class Route
{
use Concerns\HasMiddleware;
protected Closure $handler;
protected PathSegment $segment;
public function __construct(
protected HttpMethod $method,
callable $handler,
?PathSegment $segment = null,
private ?Group $group = null,
) {
$this->handler = Closure::fromCallable($handler);
if (null !== $segment) {
$this->segment = $segment;
}
}
public function getMethod(): HttpMethod
{
return $this->method;
}
public function setSegment(PathSegment $segment): void
{
$this->segment = $segment;
}
public function setGroup(Group $group): void
{
$this->group = $group;
}
public function getSegment(): PathSegment
{
return $this->segment;
}
/** @param array<string, string> $parameters */
public function getPath(array $parameters = []): string
{
return $this->segment->getPath($parameters);
}
public function getHandler(): Closure
{
return $this->handler;
}
public function getGroup(): ?Group
{
return $this->group;
}
}
|