AbstractUri::__toString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource;
6
7
use Stringable;
8
9
use function http_build_query;
10
11
abstract class AbstractUri implements Stringable
12
{
13
    /** @var string */
14
    public $scheme;
15
16
    /** @var string */
17
    public $host;
18
19
    /** @var string */
20
    public $path;
21
22
    /**
23
     * Associative query array
24
     *
25
     * @var array<string, mixed>
26
     */
27
    public $query = [];
28
29
    /** @var string */
30
    public $method = 'get';
31
32
    /** @return string */
33
    public function __toString()
34
    {
35
        return "{$this->scheme}://{$this->host}{$this->path}" . ($this->query ? '?' . http_build_query($this->query) : '');
36
    }
37
}
38