Passed
Push — master ( c2faf8...afa411 )
by Al3x
11:51
created

RequestOptions::setInclude()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace InvoiceNinjaModule\Options;
5
6
use InvoiceNinjaModule\Options\Interfaces\RequestOptionsInterface;
7
8
/**
9
 * Class RequestOptions
10
 */
11
final class RequestOptions implements RequestOptionsInterface
12
{
13
    private string $paramPageSize = 'per_page';
14
    private string $paramPage = 'page';
15
    private string $paramClientId='client_id';
16
    private string $paramUpdated='updated_at';
17
    private string $paramInclude='include';
18
    private array $additionalGetParams = [];
19
    private array $additionalPostParams = [];
20
21
/*
22
include: A comma-separated list of nested relationships to include.
23
updated_at: Timestamp used as a filter to only show recently updated records.
24
*/
25
26
    /**
27
     * @param array $params
28
     */
29 7
    public function addQueryParameters(array $params) :void
30
    {
31 7
        $this->additionalGetParams = \array_merge($params, $this->additionalGetParams);
32 7
    }
33
34
    /**
35
     * @param array $params
36
     */
37 4
    public function addPostParameters(array $params) :void
38
    {
39 4
        $this->additionalPostParams = \array_merge($params, $this->additionalPostParams);
40 4
    }
41
42
    /**
43
     * @return array
44
     */
45 2
    public function getQueryArray() :array
46
    {
47 2
        return $this->additionalGetParams;
48
    }
49
50
    /**
51
     * @return array
52
     */
53 2
    public function getPostArray() :array
54
    {
55 2
        return $this->additionalPostParams;
56
    }
57
58
59
    /**
60
     * @param int $pageSize
61
     */
62 4
    public function setPageSize(int $pageSize) :void
63
    {
64 4
        $this->additionalGetParams[$this->paramPageSize] = $pageSize;
65 4
    }
66
67
68
    /**
69
     * @param int $page
70
     */
71 4
    public function setPage(int $page) :void
72
    {
73 4
        $this->additionalGetParams[$this->paramPage] = $page;
74 4
    }
75
76
    /**
77
     * @param int $clientId
78
     */
79 1
    public function setClientId(int $clientId) :void
80
    {
81 1
        $this->additionalGetParams[$this->paramClientId] = $clientId;
82 1
    }
83
84
    /**
85
     * @param int $updated
86
     */
87 1
    public function setUpdated(int $updated) :void
88
    {
89 1
        $this->additionalGetParams[$this->paramUpdated] = $updated;
90 1
    }
91
92
    /**
93
     * @param string $include
94
     */
95 1
    public function setInclude(string $include) :void
96
    {
97 1
        $this->additionalGetParams[$this->paramInclude] = $include;
98 1
    }
99
}
100