Completed
Push — master ( 7a3efc...f79493 )
by Al3x
02:58
created

RequestOptions   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
lcom 2
cbo 0
dl 0
loc 101
c 0
b 0
f 0
rs 10
ccs 29
cts 29
cp 1

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A addQueryParameters() 0 4 1
A addPostParameters() 0 4 1
A getQueryArray() 0 4 1
A getPostArray() 0 4 1
A setPageSize() 0 4 1
A setPage() 0 4 1
A setClientId() 0 4 1
A setUpdated() 0 4 1
A setInclude() 0 4 1
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
    /** @var string  */
14
    private $paramPageSize = 'per_page';
15
    /** @var string  */
16
    private $paramPage = 'page';
17
    /** @var string  */
18
    private $paramClientId='client_id';
19
    /** @var string  */
20
    private $paramUpdated='updated_at';
21
    /** @var string  */
22
    private $paramInclude='include';
23
    /** @var array  */
24
    private $additionalGetParams;
25
    /** @var array  */
26
    private $additionalPostParams;
27
28
/*
29
include: A comma-separated list of nested relationships to include.
30
updated_at: Timestamp used as a filter to only show recently updated records.
31
*/
32 19
    public function __construct()
33
    {
34 19
        $this->additionalPostParams = [];
35 19
        $this->additionalGetParams = [];
36 19
    }
37
38
    /**
39
     * @param array $params
40
     */
41 7
    public function addQueryParameters(array $params) :void
42
    {
43 7
        $this->additionalGetParams = \array_merge($params, $this->additionalGetParams);
44 7
    }
45
46
    /**
47
     * @param array $params
48
     */
49 4
    public function addPostParameters(array $params) :void
50
    {
51 4
        $this->additionalPostParams = \array_merge($params, $this->additionalPostParams);
52 4
    }
53
54
    /**
55
     * @return array
56
     */
57 2
    public function getQueryArray() :array
58
    {
59 2
        return $this->additionalGetParams;
60
    }
61
62
    /**
63
     * @return array
64
     */
65 2
    public function getPostArray() :array
66
    {
67 2
        return $this->additionalPostParams;
68
    }
69
70
71
    /**
72
     * @param int $pageSize
73
     */
74 4
    public function setPageSize(int $pageSize) :void
75
    {
76 4
        $this->additionalGetParams[$this->paramPageSize] = $pageSize;
77 4
    }
78
79
80
    /**
81
     * @param int $page
82
     */
83 4
    public function setPage(int $page) :void
84
    {
85 4
        $this->additionalGetParams[$this->paramPage] = $page;
86 4
    }
87
88
    /**
89
     * @param int $clientId
90
     */
91 1
    public function setClientId(int $clientId) :void
92
    {
93 1
        $this->additionalGetParams[$this->paramClientId] = $clientId;
94 1
    }
95
96
    /**
97
     * @param int $updated
98
     */
99 1
    public function setUpdated(int $updated) :void
100
    {
101 1
        $this->additionalGetParams[$this->paramUpdated] = $updated;
102 1
    }
103
104
    /**
105
     * @param string $include
106
     */
107 1
    public function setInclude(string $include) :void
108
    {
109 1
        $this->additionalGetParams[$this->paramInclude] = $include;
110 1
    }
111
}
112