RouterMatch::__toString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 2
b 0
f 0
nc 2
nop 0
dl 0
loc 5
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 Stringable;
8
9
use function http_build_query;
10
11
class RouterMatch implements Stringable
12
{
13
    /** @param array<string, mixed> $query */
14
    public function __construct(
15
        public string $method = '',
16
        public string $path = '',
17
        public array $query = [],
18
    ) {
19
    }
20
21
    public function __toString(): string
22
    {
23
        $querySymbol = $this->query ? '?' : '';
24
25
        return "{$this->method} {$this->path}{$querySymbol}" . http_build_query($this->query);
26
    }
27
}
28