Passed
Pull Request — master (#60)
by
unknown
10:40
created

MatchingResult   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
c 2
b 0
f 0
dl 0
loc 41
ccs 18
cts 18
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A isSuccess() 0 3 1
A fromSuccess() 0 8 1
A fromFailure() 0 6 1
A __construct() 0 2 1
A getRoute() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Router;
6
7
use Yiisoft\Router\Route\RouteInterface;
8
9
final class MatchingResult
10
{
11
    private RouteInterface $route;
12
    private array $parameters;
13
    private bool $success;
14
15
    private function __construct()
16
    {
17
    }
18
19
    public static function fromSuccess(RouteInterface $route, array $parameters): self
20 8
    {
21
        $result = new self();
22 8
        $result->success = true;
23
        $result->route = $route;
24 1
        $result->parameters = $parameters;
25
26 1
        return $result;
27 1
    }
28 1
29
    public static function fromFailure(): self
30
    {
31 3
        $result = new self();
32
        $result->success = false;
33 3
34 3
        return $result;
35 3
    }
36 3
37 3
    /**
38
     * Get the route for which matching was done.
39
     *
40 5
     * @return RouteInterface
41
     */
42 5
    public function getRoute(): RouteInterface
43 5
    {
44 5
        return $this->route;
45 5
    }
46
47
    public function isSuccess(): bool
48 5
    {
49
        return $this->success;
50 5
    }
51
}
52