Completed
Push — 1.x ( f4fdd6...6ecbf3 )
by Akihito
14s queued 11s
created

RouterMatch   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 2 Features 0
Metric Value
wmc 3
eloc 8
c 5
b 2
f 0
dl 0
loc 38
ccs 3
cts 3
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 5 2
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Sunday\Extension\Router;
6
7
use function http_build_query;
8
9
class RouterMatch
10
{
11
    /**
12
     * Request method
13
     *
14
     * @var string
15
     */
16
    public $method;
17
18
    /**
19
     * Request path
20
     *
21
     * @var string
22
     */
23
    public $path;
24
25
    /**
26
     * Request query
27
     *
28
     * @var array<string, mixed>
29
     */
30 2
    public $query = [];
31
32 2
    /**
33
     * @param array<string, mixed> $query
34 2
     */
35
    public function __construct(string $method = '', string $path = '', array $query = [])
36
    {
37
        $this->method = $method;
38
        $this->path = $path;
39
        $this->query = $query;
40
    }
41
42
    public function __toString(): string
43
    {
44
        $querySymbol = $this->query ? '?' : '';
45
46
        return "{$this->method} {$this->path}{$querySymbol}" . http_build_query($this->query);
47
    }
48
}
49