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

UrlMatcherInterfaceProxy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 34
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentUri() 0 3 1
A getCurrentRoute() 0 3 1
A __construct() 0 4 1
A match() 0 7 1
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