Completed
Push — master ( bec978...be88d7 )
by Peter
01:42
created

PlayersQuery   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 93.33%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 37
ccs 14
cts 15
cp 0.9333
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 4 1
A forPlayerIds() 0 6 1
A toQueryString() 0 13 3
1
<?php
2
3
namespace PtrTn\Battlerite\Query;
4
5
use Webmozart\Assert\Assert;
6
7
class PlayersQuery
8
{
9
    /**
10
     * @var string[]
11
     */
12
    private $playerIds;
13
14 1
    private function __construct()
15
    {
16 1
    }
17
18 1
    public static function create(): self
19
    {
20 1
        return new self();
21
    }
22
23 1
    public function forPlayerIds(array $playerIds)
24
    {
25 1
        Assert::allString($playerIds, 'Specified player ids should be an array of strings');
26 1
        $this->playerIds = $playerIds;
27 1
        return $this;
28
    }
29
30 1
    public function toQueryString(): ?string
31
    {
32 1
        $query = [];
33 1
        if (!empty($this->playerIds)) {
34 1
            $query['filter[playerIds]'] = implode(',', $this->playerIds);
35
        }
36
37 1
        if (!empty($query)) {
38 1
            return http_build_query($query);
39
        }
40
41
        return null;
42
    }
43
}
44