Passed
Pull Request — develop (#492)
by nikos
11:03 queued 10s
created

StoreRequestBuilder::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
// phpcs:disable Generic.Files.LineLength
3
namespace Commercetools\Core\Builder\Request;
4
5
use Commercetools\Core\Request\Stores\StoreByIdGetRequest;
6
use Commercetools\Core\Request\Stores\StoreByKeyGetRequest;
7
use Commercetools\Core\Request\Stores\StoreCreateRequest;
8
use Commercetools\Core\Model\Store\StoreDraft;
9
use Commercetools\Core\Request\Stores\StoreDeleteByKeyRequest;
10
use Commercetools\Core\Model\Store\Store;
11
use Commercetools\Core\Request\Stores\StoreDeleteRequest;
12
use Commercetools\Core\Request\Stores\StoreQueryRequest;
13
use Commercetools\Core\Request\Stores\StoreUpdateByKeyRequest;
14
use Commercetools\Core\Request\Stores\StoreUpdateRequest;
15
16
class StoreRequestBuilder
17
{
18
19
    /**
20
     * @link https://docs.commercetools.com/http-api-projects-stores#get-a-store-by-id
21
     * @param string $id
22
     * @return StoreByIdGetRequest
23
     */
24 1
    public function getById($id)
25
    {
26 1
        $request = StoreByIdGetRequest::ofId($id);
27 1
        return $request;
28
    }
29
30
    /**
31
     * @link https://docs.commercetools.com/http-api-projects-stores#get-a-store-by-key
32
     * @param string $key
33
     * @return StoreByKeyGetRequest
34
     */
35 1
    public function getByKey($key)
36
    {
37 1
        $request = StoreByKeyGetRequest::ofKey($key);
38 1
        return $request;
39
    }
40
41
    /**
42
     * @link https://docs.commercetools.com/http-api-projects-stores#create-a-store
43
     * @param StoreDraft $store
44
     * @return StoreCreateRequest
45
     */
46 1
    public function create(StoreDraft $store)
47
    {
48 1
        $request = StoreCreateRequest::ofDraft($store);
49 1
        return $request;
50
    }
51
52
    /**
53
     * @link https://docs.commercetools.com/http-api-projects-stores#delete-store-by-key
54
     * @param Store $store
55
     * @return StoreDeleteByKeyRequest
56
     */
57 1
    public function deleteByKey(Store $store)
58
    {
59 1
        $request = StoreDeleteByKeyRequest::ofKeyAndVersion($store->getKey(), $store->getVersion());
60 1
        return $request;
61
    }
62
63
    /**
64
     * @link https://docs.commercetools.com/http-api-projects-stores#delete-store-by-id
65
     * @param Store $store
66
     * @return StoreDeleteRequest
67
     */
68 1
    public function delete(Store $store)
69
    {
70 1
        $request = StoreDeleteRequest::ofIdAndVersion($store->getId(), $store->getVersion());
71 1
        return $request;
72
    }
73
74
    /**
75
     * @link https://docs.commercetools.com/http-api-projects-stores#query-stores
76
     *
77
     * @return StoreQueryRequest
78
     */
79 1
    public function query()
80
    {
81 1
        $request = StoreQueryRequest::of();
82 1
        return $request;
83
    }
84
85
    /**
86
     * @link https://docs.commercetools.com/http-api-projects-stores#update-store-by-key
87
     * @param Store $store
88
     * @return StoreUpdateByKeyRequest
89
     */
90 1
    public function updateByKey(Store $store)
91
    {
92 1
        $request = StoreUpdateByKeyRequest::ofKeyAndVersion($store->getKey(), $store->getVersion());
93 1
        return $request;
94
    }
95
96
    /**
97
     * @link https://docs.commercetools.com/http-api-projects-stores#update-store-by-id
98
     * @param Store $store
99
     * @return StoreUpdateRequest
100
     */
101 1
    public function update(Store $store)
102
    {
103 1
        $request = StoreUpdateRequest::ofIdAndVersion($store->getId(), $store->getVersion());
104 1
        return $request;
105
    }
106
107
    /**
108
     * @return StoreRequestBuilder
109
     */
110
    public function of()
111
    {
112
        return new self();
113
    }
114
}
115