forked from nikic/FastRoute
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoute.php
More file actions
43 lines (34 loc) · 840 Bytes
/
Copy pathRoute.php
File metadata and controls
43 lines (34 loc) · 840 Bytes
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
<?php
declare(strict_types=1);
namespace FastRoute;
use function preg_match;
class Route
{
/** @var string */
public $httpMethod;
/** @var string */
public $regex;
/** @var mixed[] */
public $variables;
/** @var mixed */
public $handler;
/**
* @param mixed $handler
* @param mixed[] $variables
*/
public function __construct(string $httpMethod, $handler, string $regex, array $variables)
{
$this->httpMethod = $httpMethod;
$this->handler = $handler;
$this->regex = $regex;
$this->variables = $variables;
}
/**
* Tests whether this route matches the given string.
*/
public function matches(string $str): bool
{
$regex = '~^' . $this->regex . '$~';
return (bool) preg_match($regex, $str);
}
}