Passed
Push — master ( 7391a5...b4a1d2 )
by Alexander
03:03
created

UrlMatcherInterfaceProxy::getCurrentRoute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Proxy;
6
7
use Psr\Http\Message\ServerRequestInterface;
8
use Psr\Http\Message\UriInterface;
9
use Yiisoft\Router\MatchingResult;
10
use Yiisoft\Router\Route;
11
use Yiisoft\Router\UrlMatcherInterface;
12
use Yiisoft\Yii\Debug\Collector\RouterCollectorInterface;
13
14
final class UrlMatcherInterfaceProxy implements UrlMatcherInterface
15
{
16
    private UrlMatcherInterface $urlMatcher;
17
    private RouterCollectorInterface $routerCollector;
18
19 1
    public function __construct(UrlMatcherInterface $urlMatcher, RouterCollectorInterface $routerCollector)
20
    {
21 1
        $this->urlMatcher = $urlMatcher;
22 1
        $this->routerCollector = $routerCollector;
23 1
    }
24
25 1
    public function match(ServerRequestInterface $request): MatchingResult
26
    {
27 1
        $timeStart = microtime(true);
28 1
        $result = $this->urlMatcher->match($request);
29 1
        $this->routerCollector->collect(microtime(true) - $timeStart);
30
31 1
        return $result;
32
    }
33
34
    /**
35
     * @codeCoverageIgnore
36
     */
37
    public function getCurrentRoute(): ?Route
38
    {
39
        return $this->urlMatcher->getCurrentRoute();
40
    }
41
42
    /**
43
     * @codeCoverageIgnore
44
     */
45
    public function getCurrentUri(): ?UriInterface
46
    {
47
        return $this->urlMatcher->getCurrentUri();
48
    }
49
}
50