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

MatchingResult::getRoute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 3
cts 3
cp 1
crap 1
rs 10
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