HasGetQuery::withQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Reviewsio\Endpoints;
4
5
trait HasGetQuery
6
{
7
    protected array $query = [];
8
9 2
    public function withQuery(array $query = []): static
10
    {
11 2
        $this->query = array_merge($this->query, $query);
12
13 2
        return $this;
14
    }
15
16 2
    public function addParameterToQuery(string $parameter, mixed $value = null): static
17
    {
18 2
        $this->query[$parameter] = $value;
19
20 2
        return $this;
21
    }
22
23 1
    public function removeParameterFromQuery(string $parameter): static
24
    {
25 1
        if (isset($this->query[$parameter])) {
26 1
            unset($this->query[$parameter]);
27
        }
28
29 1
        return $this;
30
    }
31
32 2
    public function query(): array
33
    {
34 2
        return $this->query;
35
    }
36
}
37