Completed
Push — master ( 122bdb...4f8f85 )
by Jens
10:49 queued 41s
created

PriceSelectTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 48
ccs 8
cts 12
cp 0.6667
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A channel() 0 4 1
A customerGroup() 0 4 1
A select() 0 8 2
A currency() 0 4 1
A country() 0 4 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Request;
7
8
use Commercetools\Core\Model\Channel\ChannelReference;
9
use Commercetools\Core\Model\CustomerGroup\CustomerGroupReference;
10
use Commercetools\Core\Request\Query\Parameter;
11
use Commercetools\Core\Request\Query\ParameterInterface;
12
13
/**
14
 * @method $this addParamObject(ParameterInterface $param)
15
 */
16
trait PriceSelectTrait
17
{
18
19 7
    protected function select($key, $value)
20
    {
21 7
        if (!is_null($value)) {
22 7
            $this->addParamObject(new Parameter($key, $value));
23
        }
24
25 7
        return $this;
26
    }
27
28
    /**
29
     * @param string $currency
30
     * @return $this
31
     */
32 7
    public function currency($currency)
33
    {
34 7
        return $this->select('priceCurrency', $currency);
35
    }
36
37
    /**
38
     * @param string $country
39
     * @return $this
40
     */
41 1
    public function country($country)
42
    {
43 1
        return $this->select('priceCountry', $country);
44
    }
45
46
    /**
47
     * @param ChannelReference $channel
48
     * @return $this
49
     */
50
    public function channel(ChannelReference $channel)
51
    {
52
        return $this->select('priceChannel', $channel->getId());
53
    }
54
55
    /**
56
     * @param CustomerGroupReference $customerGroup
57
     * @return $this
58
     */
59
    public function customerGroup(CustomerGroupReference $customerGroup)
60
    {
61
        return $this->select('priceCustomerGroup', $customerGroup->getId());
62
    }
63
}
64