Passed
Push — develop ( f53d0b...3a55e6 )
by Jens
09:08
created

StateRequestBuilder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 44
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A getById() 0 3 1
A query() 0 3 1
A update() 0 3 1
A delete() 0 3 1
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Builder\Request;
7
8
use Commercetools\Core\Model\State\State;
9
use Commercetools\Core\Model\State\StateDraft;
10
use Commercetools\Core\Request\States\StateByIdGetRequest;
11
use Commercetools\Core\Request\States\StateCreateRequest;
12
use Commercetools\Core\Request\States\StateDeleteRequest;
13
use Commercetools\Core\Request\States\StateQueryRequest;
14
use Commercetools\Core\Request\States\StateUpdateRequest;
15
16
class StateRequestBuilder
17
{
18
    /**
19
     * @return StateQueryRequest
20
     */
21 1
    public function query()
22
    {
23 1
        return StateQueryRequest::of();
24
    }
25
26
    /**
27
     * @param State $state
28
     * @return StateUpdateRequest
29
     */
30 1
    public function update(State $state)
31
    {
32 1
        return StateUpdateRequest::ofIdAndVersion($state->getId(), $state->getVersion());
33
    }
34
35
    /**
36
     * @param StateDraft $stateDraft
37
     * @return StateCreateRequest
38
     */
39 1
    public function create(StateDraft $stateDraft)
40
    {
41 1
        return StateCreateRequest::ofDraft($stateDraft);
42
    }
43
44
    /**
45
     * @param State $state
46
     * @return StateDeleteRequest
47
     */
48 1
    public function delete(State $state)
49
    {
50 1
        return StateDeleteRequest::ofIdAndVersion($state->getId(), $state->getVersion());
51
    }
52
53
    /**
54
     * @param string $id
55
     * @return StateByIdGetRequest
56
     */
57 1
    public function getById($id)
58
    {
59 1
        return StateByIdGetRequest::ofId($id);
60
    }
61
}
62