Passed
Push — master ( 18b32f...fa2b73 )
by Jens
08:15
created

StateRequestBuilder   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 88.24%

Importance

Changes 0
Metric Value
wmc 6
eloc 12
dl 0
loc 64
ccs 15
cts 17
cp 0.8824
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A getById() 0 4 1
A query() 0 4 1
A of() 0 3 1
A update() 0 4 1
A delete() 0 4 1
1
<?php
2
// phpcs:disable Generic.Files.LineLength
3
namespace Commercetools\Core\Builder\Request;
4
5
use Commercetools\Core\Request\States\StateByIdGetRequest;
6
use Commercetools\Core\Request\States\StateCreateRequest;
7
use Commercetools\Core\Model\State\StateDraft;
8
use Commercetools\Core\Request\States\StateDeleteRequest;
9
use Commercetools\Core\Model\State\State;
10
use Commercetools\Core\Request\States\StateQueryRequest;
11
use Commercetools\Core\Request\States\StateUpdateRequest;
12
13
class StateRequestBuilder
14
{
15
16
    /**
17
     * @link https://docs.commercetools.com/http-api-projects-states.html#get-state-by-id
18
     * @param string $id
19
     * @return StateByIdGetRequest
20
     */
21 1
    public function getById($id)
22
    {
23 1
        $request = StateByIdGetRequest::ofId($id);
24 1
        return $request;
25
    }
26
27
    /**
28
     * @link https://docs.commercetools.com/http-api-projects-states.html#create-state
29
     * @param StateDraft $state
30
     * @return StateCreateRequest
31
     */
32 1
    public function create(StateDraft $state)
33
    {
34 1
        $request = StateCreateRequest::ofDraft($state);
35 1
        return $request;
36
    }
37
38
    /**
39
     * @link https://docs.commercetools.com/http-api-projects-states.html#delete-state
40
     * @param State $state
41
     * @return StateDeleteRequest
42
     */
43 1
    public function delete(State $state)
44
    {
45 1
        $request = StateDeleteRequest::ofIdAndVersion($state->getId(), $state->getVersion());
46 1
        return $request;
47
    }
48
49
    /**
50
     * @link https://docs.commercetools.com/http-api-projects-states.html#query-states
51
     *
52
     * @return StateQueryRequest
53
     */
54 1
    public function query()
55
    {
56 1
        $request = StateQueryRequest::of();
57 1
        return $request;
58
    }
59
60
    /**
61
     * @link https://docs.commercetools.com/http-api-projects-states.html#update-state
62
     * @param State $state
63
     * @return StateUpdateRequest
64
     */
65 1
    public function update(State $state)
66
    {
67 1
        $request = StateUpdateRequest::ofIdAndVersion($state->getId(), $state->getVersion());
68 1
        return $request;
69
    }
70
71
    /**
72
     * @return StateRequestBuilder
73
     */
74
    public function of()
75
    {
76
        return new self();
77
    }
78
}
79