RouterMatch::__toString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 2
b 0
f 0
nc 2
nop 0
dl 0
loc 6
ccs 0
cts 0
cp 0
crap 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Sunday\Extension\Router;
6
7
use Override;
8
use Stringable;
9
10
use function http_build_query;
11
12
class RouterMatch implements Stringable
13
{
14
    /** @param array<string, mixed> $query */
15
    public function __construct(
16
        public string $method = '',
17
        public string $path = '',
18
        public array $query = [],
19
    ) {
20
    }
21
22
    #[Override]
23
    public function __toString(): string
24
    {
25
        $querySymbol = $this->query ? '?' : '';
26
27
        return "{$this->method} {$this->path}{$querySymbol}" . http_build_query($this->query);
28
    }
29
}
30