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

GiftLineItemCartDiscountValue::fieldDefinitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

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