Completed
Push — develop ( c1c65f...ad5811 )
by Jens
08:43
created

GiftLineItemCartDiscountValue   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 34
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A fieldDefinitions() 0 10 1
A ofProductAndVariantId() 0 4 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\CartDiscount;
7
8
use Commercetools\Core\Model\Channel\ChannelReference;
9
use Commercetools\Core\Model\Common\Context;
10
use Commercetools\Core\Model\Product\ProductReference;
11
12
/**
13
 * @package Commercetools\Core\Model\CartDiscount
14
 *
15
 * @method string getType()
16
 * @method GiftLineItemCartDiscountValue setType(string $type = null)
17
 * @method ProductReference getProduct()
18
 * @method GiftLineItemCartDiscountValue setProduct(ProductReference $product = null)
19
 * @method int getVariantId()
20
 * @method GiftLineItemCartDiscountValue setVariantId(int $variantId = null)
21
 * @method ChannelReference getSupplyChannel()
22
 * @method GiftLineItemCartDiscountValue setSupplyChannel(ChannelReference $supplyChannel = null)
23
 * @method ChannelReference getDistributionChannel()
24
 * @method GiftLineItemCartDiscountValue setDistributionChannel(ChannelReference $distributionChannel = null)
25
 */
26
class GiftLineItemCartDiscountValue extends CartDiscountValue
0 ignored issues
show
Deprecated Code introduced by
The class Commercetools\Core\Model...count\CartDiscountValue has been deprecated with message: use RelativeCartDiscountValue, AbsoluteCartDiscountValue or GiftLineItemCartDiscountValue instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
27
{
28
    /**
29
     * @inheritDoc
30
     */
31 1
    public function __construct(array $data = [], $context = null)
32
    {
33 1
        $data['type'] = static::TYPE_GIFT_LINE_ITEM;
34
35 1
        parent::__construct($data, $context);
36 1
    }
37
38 1
    public function fieldDefinitions()
39
    {
40
        return [
41 1
            'type' => [static::TYPE => 'string'],
42 1
            'product' => [static::TYPE => ProductReference::class],
43 1
            'variantId' => [static::TYPE => 'int'],
44 1
            'supplyChannel' => [static::TYPE => ChannelReference::class],
45 1
            'distributionChannel' => [static::TYPE => ChannelReference::class],
46
        ];
47
    }
48
49
    /**
50
     * @param ProductReference $product
51
     * @param int $variantId
52
     * @param Context|callable $context
53
     * @return GiftLineItemCartDiscountValue
54
     */
55
    public static function ofProductAndVariantId(ProductReference $product, $variantId, $context = null)
56
    {
57
        return static::of($context)->setProduct($product)->setVariantId($variantId);
58
    }
59
}
60