Passed
Branch request_builder (fdca7a)
by Jens
08:39
created

CartRequestBuilder   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 53
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A query() 0 3 1
A update() 0 3 1
A delete() 0 3 1
A getById() 0 3 1
A getByCustomerId() 0 3 1
A create() 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\Cart\Cart;
9
use Commercetools\Core\Model\Cart\CartDraft;
10
use Commercetools\Core\Request\Carts\CartByCustomerIdGetRequest;
11
use Commercetools\Core\Request\Carts\CartByIdGetRequest;
12
use Commercetools\Core\Request\Carts\CartCreateRequest;
13
use Commercetools\Core\Request\Carts\CartDeleteRequest;
14
use Commercetools\Core\Request\Carts\CartQueryRequest;
15
use Commercetools\Core\Request\Carts\CartUpdateRequest;
16
17
class CartRequestBuilder
18
{
19
    /**
20
     * @return CartQueryRequest
21
     */
22 1
    public function query()
23
    {
24 1
        return CartQueryRequest::of();
25
    }
26
27
    /**
28
     * @param Cart $cart
29
     * @return CartUpdateRequest
30
     */
31 1
    public function update(Cart $cart)
32
    {
33 1
        return CartUpdateRequest::ofIdAndVersion($cart->getId(), $cart->getVersion());
34
    }
35
36
    /**
37
     * @param CartDraft $cartDraft
38
     * @return CartCreateRequest
39
     */
40 1
    public function create(CartDraft $cartDraft)
41
    {
42 1
        return CartCreateRequest::ofDraft($cartDraft);
43
    }
44
45
    /**
46
     * @param Cart $cart
47
     * @return CartDeleteRequest
48
     */
49 1
    public function delete(Cart $cart)
50
    {
51 1
        return CartDeleteRequest::ofIdAndVersion($cart->getId(), $cart->getVersion());
52
    }
53
54
    /**
55
     * @param string $id
56
     * @return CartByIdGetRequest
57
     */
58 1
    public function getById($id)
59
    {
60 1
        return CartByIdGetRequest::ofId($id);
61
    }
62
63
    /**
64
     * @param string $customerId
65
     * @return CartByCustomerIdGetRequest
66
     */
67
    public function getByCustomerId($customerId)
68
    {
69
        return CartByCustomerIdGetRequest::ofCustomerId($customerId);
70
    }
71
}
72