1 | <?php |
||
18 | final class Matching implements Authentication |
||
19 | { |
||
20 | /** |
||
21 | * @var Authentication |
||
22 | */ |
||
23 | private $authentication; |
||
24 | |||
25 | /** |
||
26 | * @var CallbackRequestMatcher |
||
27 | */ |
||
28 | private $matcher; |
||
29 | |||
30 | /** |
||
31 | * @param Authentication $authentication |
||
32 | * @param callable|null $matcher |
||
33 | */ |
||
34 | 5 | public function __construct(Authentication $authentication, callable $matcher = null) |
|
35 | { |
||
36 | 5 | if (is_null($matcher)) { |
|
37 | $matcher = function () { |
||
38 | return true; |
||
39 | }; |
||
40 | } |
||
41 | |||
42 | 5 | $this->authentication = $authentication; |
|
43 | 5 | $this->matcher = new CallbackRequestMatcher($matcher); |
|
44 | 5 | } |
|
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | 2 | public function authenticate(RequestInterface $request) |
|
57 | |||
58 | /** |
||
59 | * Creates a matching authentication for an URL. |
||
60 | * |
||
61 | * @param Authentication $authentication |
||
62 | * @param string $url |
||
63 | * |
||
64 | * @return self |
||
65 | */ |
||
66 | public static function createUrlMatcher(Authentication $authentication, $url) |
||
74 | } |
||
75 |
If you suppress an error, we recommend checking for the error condition explicitly: