PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / php-http / message / src / RequestMatcher / RequestMatcher.php
ameliabooking / vendor / php-http / message / src / RequestMatcher Last commit date
CallbackRequestMatcher.php 6 months ago RegexRequestMatcher.php 6 months ago RequestMatcher.php 6 months ago
RequestMatcher.php
79 lines
1 <?php
2
3 namespace AmeliaHttp\Message\RequestMatcher;
4
5 use AmeliaHttp\Message\RequestMatcher as RequestMatcherInterface;
6 use AmeliaVendor\Psr\Http\Message\RequestInterface;
7
8 /**
9 * A port of the Symfony RequestMatcher for PSR-7.
10 *
11 * @author Fabien Potencier <fabien@symfony.com>
12 * @author Joel Wurtz <joel.wurtz@gmail.com>
13 */
14 final class RequestMatcher implements RequestMatcherInterface
15 {
16 /**
17 * @var string
18 */
19 private $path;
20
21 /**
22 * @var string
23 */
24 private $host;
25
26 /**
27 * @var array
28 */
29 private $methods = [];
30
31 /**
32 * @var string[]
33 */
34 private $schemes = [];
35
36 /**
37 * The regular expressions used for path or host must be specified without delimiter.
38 * You do not need to escape the forward slash / to match it.
39 *
40 * @param string|null $path Regular expression for the path
41 * @param string|null $host Regular expression for the hostname
42 * @param string|string[]|null $methods Method or list of methods to match
43 * @param string|string[]|null $schemes Scheme or list of schemes to match (e.g. http or https)
44 */
45 public function __construct($path = null, $host = null, $methods = [], $schemes = [])
46 {
47 $this->path = $path;
48 $this->host = $host;
49 $this->methods = array_map('strtoupper', (array) $methods);
50 $this->schemes = array_map('strtolower', (array) $schemes);
51 }
52
53 /**
54 * {@inheritdoc}
55 *
56 * @api
57 */
58 public function matches(RequestInterface $request)
59 {
60 if ($this->schemes && !in_array($request->getUri()->getScheme(), $this->schemes)) {
61 return false;
62 }
63
64 if ($this->methods && !in_array($request->getMethod(), $this->methods)) {
65 return false;
66 }
67
68 if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getUri()->getPath()))) {
69 return false;
70 }
71
72 if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getUri()->getHost())) {
73 return false;
74 }
75
76 return true;
77 }
78 }
79