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

RouterMatch::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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