HasGetQuery   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A withQuery() 0 5 1
A removeParameterFromQuery() 0 7 2
A query() 0 3 1
A addParameterToQuery() 0 5 1
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