MatchProvider::match()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
4
namespace Xervice\Routing\Business\Model\Matcher;
5
6
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\Routing\Matcher\UrlMatcher;
9
10
class MatchProvider implements MatchProviderInterface
11
{
12
    /**
13
     * @var \Symfony\Component\Routing\Matcher\UrlMatcher
14
     */
15
    private $urlMatcher;
16
17
    /**
18
     * @var \Symfony\Component\HttpFoundation\Request
19
     */
20
    private $request;
21
22
    /**
23
     * MatchProvider constructor.
24
     *
25
     * @param \Symfony\Component\Routing\Matcher\UrlMatcher $urlMatcher
26
     * @param \Symfony\Component\HttpFoundation\Request $request
27
     */
28 3
    public function __construct(UrlMatcher $urlMatcher, Request $request)
29
    {
30 3
        $this->urlMatcher = $urlMatcher;
31 3
        $this->request = $request;
32 3
    }
33
34
    /**
35
     * @param string $url
36
     *
37
     * @return array
38
     * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException
39
     * @throws \Symfony\Component\Routing\Exception\NoConfigurationException
40
     * @throws \Symfony\Component\Routing\Exception\MethodNotAllowedException
41
     */
42 3
    public function match(string $url): array
43
    {
44 3
        return $this->urlMatcher->match($url);
45
    }
46
47
    /**
48
     * @return array
49
     */
50
    public function matchRequest(): array
51
    {
52
        return $this->urlMatcher->matchRequest($this->request);
53
    }
54
}