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

PriceSelectTrait::customerGroup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
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