Passed
Push — main ( 036cf0...c6d071 )
by Konstantin
02:04
created

QueryBuilder::setExcludeFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kosv\RandomUser\Client;
6
7
use Kosv\RandomUser\Interfaces\QueryBuilderInterface;
8
use Kosv\RandomUser\Url\AbstractBuilder as AbstractUrlBuilder;
9
use Kosv\RandomUser\Url\Builder as UrlBuilder;
10
11
final class QueryBuilder implements QueryBuilderInterface
12
{
13
    private UrlBuilder $url;
14
15
    public function __construct()
16
    {
17
        $this->url = new UrlBuilder();
18
    }
19
20
    public function build(): AbstractUrlBuilder
21
    {
22
        return clone $this->url;
23
    }
24
25
    /**
26
     * @return $this
27
     */
28
    public function setExcludeFields(array $fields)
29
    {
30
        $this->url->setParam('exc', $fields);
31
        return $this;
32
    }
33
34
    /**
35
     * @return $this
36
     */
37
    public function setGenderFilter(string $gender)
38
    {
39
        $this->url->setParam('gender', [$gender]);
40
        return $this;
41
    }
42
43
    /**
44
     * @return $this
45
     */
46
    public function setIncludeFields(array $fields)
47
    {
48
        $this->url->setParam('inc', $fields);
49
        return $this;
50
    }
51
52
    /**
53
     * @return $this
54
     */
55
    public function setNationalityFilter(array $nationalities)
56
    {
57
        $this->url->setParam('nat', $nationalities);
58
        return $this;
59
    }
60
61
    /**
62
     * @return $this
63
     */
64
    public function setMaxResult(int $max)
65
    {
66
        $this->url->setParam('results', [$max]);
67
        return $this;
68
    }
69
70
    /**
71
     * @return $this
72
     */
73
    public function setPage(int $page)
74
    {
75
        $this->url->setParam('page', [$page]);
76
        return $this;
77
    }
78
79
    /**
80
     * @return $this
81
     */
82
    public function setPasswordFormat(array $format)
83
    {
84
        $this->url->setParam('password', $format);
85
        return $this;
86
    }
87
}
88