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

ProductProjectionRequestBuilder   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 68
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getByKey() 0 3 1
A getById() 0 3 1
A suggest() 0 3 1
A getBySlug() 0 3 1
A getBySku() 0 3 1
A query() 0 3 1
A search() 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\Common\LocalizedString;
9
use Commercetools\Core\Request\Products\ProductProjectionByIdGetRequest;
10
use Commercetools\Core\Request\Products\ProductProjectionByKeyGetRequest;
11
use Commercetools\Core\Request\Products\ProductProjectionBySkuGetRequest;
12
use Commercetools\Core\Request\Products\ProductProjectionBySlugGetRequest;
13
use Commercetools\Core\Request\Products\ProductProjectionQueryRequest;
14
use Commercetools\Core\Request\Products\ProductProjectionSearchRequest;
15
use Commercetools\Core\Request\Products\ProductsSuggestRequest;
16
17
class ProductProjectionRequestBuilder
18
{
19
    /**
20
     * @param bool $staged
21
     * @return ProductProjectionQueryRequest
22
     */
23
    public function query($staged = false)
24
    {
25
        return ProductProjectionQueryRequest::of()->staged($staged);
26
    }
27
28
    /**
29
     * @param bool $staged
30
     * @return ProductProjectionSearchRequest
31
     */
32
    public function search($staged = false)
33
    {
34
        return ProductProjectionSearchRequest::of()->staged($staged);
35
    }
36
37
    /**
38
     * @param string $id
39
     * @param bool $staged
40
     * @return ProductProjectionByIdGetRequest
41
     */
42
    public function getById($id, $staged = false)
43
    {
44
        return ProductProjectionByIdGetRequest::ofId($id)->staged($staged);
45
    }
46
47
    /**
48
     * @param string $key
49
     * @param bool $staged
50
     * @return ProductProjectionByKeyGetRequest
51
     */
52
    public function getByKey($key, $staged = false)
53
    {
54
        return ProductProjectionByKeyGetRequest::ofKey($key)->staged($staged);
55
    }
56
57
    /**
58
     * @param string $sku
59
     * @param bool $staged
60
     * @return ProductProjectionBySkuGetRequest
61
     */
62
    public function getBySku($sku, $staged = false)
63
    {
64
        return ProductProjectionBySkuGetRequest::ofSku($sku)->staged($staged);
65
    }
66
67
    /**
68
     * @param string $slug
69
     * @param array $languages
70
     * @param bool $staged
71
     * @return ProductProjectionBySlugGetRequest
72
     */
73
    public function getBySlug($slug, array $languages, $staged = false)
74
    {
75
        return ProductProjectionBySlugGetRequest::ofSlugAndLanguages($slug, $languages)->staged($staged);
76
    }
77
78
    /**
79
     * @param LocalizedString $keywords
80
     * @return ProductsSuggestRequest
81
     */
82
    public function suggest(LocalizedString $keywords)
83
    {
84
        return ProductsSuggestRequest::ofKeywords($keywords);
85
    }
86
}
87