Completed
Push — develop ( 555ccb...2ef543 )
by
unknown
10:33
created

CartDraft   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 40
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B fieldDefinitions() 0 24 1
A ofCurrency() 0 5 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Cart;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Model\Common\JsonObject;
10
use Commercetools\Core\Model\Common\LocaleTrait;
11
use Commercetools\Core\Model\CustomerGroup\CustomerGroupReference;
12
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft;
13
use Commercetools\Core\Model\Common\Address;
14
use Commercetools\Core\Model\ShippingMethod\ShippingMethodReference;
15
16
/**
17
 * @package Commercetools\Core\Model\Cart
18
 * @link https://dev.commercetools.com/http-api-projects-carts.html#cartdraft
19
 * @method string getCurrency()
20
 * @method string getCustomerId()
21
 * @method string getCountry()
22
 * @method string getInventoryMode()
23
 * @method CartDraft setCurrency(string $currency = null)
24
 * @method CartDraft setCustomerId(string $customerId = null)
25
 * @method CartDraft setCountry(string $country = null)
26
 * @method CartDraft setInventoryMode(string $inventoryMode = null)
27
 * @method CustomFieldObjectDraft getCustom()
28
 * @method CartDraft setCustom(CustomFieldObjectDraft $custom = null)
29
 * @method string getCustomerEmail()
30
 * @method CartDraft setCustomerEmail(string $customerEmail = null)
31
 * @method LineItemDraftCollection getLineItems()
32
 * @method CartDraft setLineItems(LineItemDraftCollection $lineItems = null)
33
 * @method Address getShippingAddress()
34
 * @method CartDraft setShippingAddress(Address $shippingAddress = null)
35
 * @method Address getBillingAddress()
36
 * @method CartDraft setBillingAddress(Address $billingAddress = null)
37
 * @method ShippingMethodReference getShippingMethod()
38
 * @method CartDraft setShippingMethod(ShippingMethodReference $shippingMethod = null)
39
 * @method CustomLineItemDraftCollection getCustomLineItems()
40
 * @method CartDraft setCustomLineItems(CustomLineItemDraftCollection $customLineItems = null)
41
 * @method string getTaxMode()
42
 * @method CartDraft setTaxMode(string $taxMode = null)
43
 * @method string getAnonymousId()
44
 * @method CartDraft setAnonymousId(string $anonymousId = null)
45
 * @method string getLocale()
46
 * @method string getTaxRoundingMode()
47
 * @method CartDraft setTaxRoundingMode(string $taxRoundingMode = null)
48
 * @method int getDeleteDaysAfterLastModification()
49
 * @method CartDraft setDeleteDaysAfterLastModification(int $deleteDaysAfterLastModification = null)
50
 * @method CustomerGroupReference getCustomerGroup()
51
 * @method CartDraft setCustomerGroup(CustomerGroupReference $customerGroup = null)
52
 * @method string getOrigin()
53
 * @method CartDraft setOrigin(string $origin = null)
54
 * @method string getTaxCalculationMode()
55
 * @method CartDraft setTaxCalculationMode(string $taxCalculationMode = null)
56
 */
57
class CartDraft extends JsonObject
58
{
59
    use LocaleTrait;
60
61 128
    public function fieldDefinitions()
62
    {
63
        return [
64 128
            'currency' => [static::TYPE => 'string'],
65 128
            'customerId' => [static::TYPE => 'string'],
66 128
            'customerEmail' => [static::TYPE => 'string'],
67 128
            'country' => [static::TYPE => 'string'],
68 128
            'inventoryMode' => [static::TYPE => 'string'],
69 128
            'lineItems' => [static::TYPE => LineItemDraftCollection::class],
70 128
            'customLineItems' => [static::TYPE => CustomLineItemDraftCollection::class],
71 128
            'shippingAddress' => [static::TYPE => Address::class],
72 128
            'billingAddress' => [static::TYPE => Address::class],
73 128
            'shippingMethod' => [static::TYPE => ShippingMethodReference::class],
74 128
            'custom' => [static::TYPE => CustomFieldObjectDraft::class],
75 128
            'taxMode' => [static::TYPE => 'string'],
76 128
            'anonymousId' => [static::TYPE => 'string'],
77 128
            'locale' => [static::TYPE => 'string'],
78 128
            'taxRoundingMode' => [static::TYPE => 'string'],
79 128
            'deleteDaysAfterLastModification' => [static::TYPE => 'int'],
80 128
            'customerGroup' => [static::TYPE => CustomerGroupReference::class],
81 128
            'origin' => [static::TYPE => 'string'],
82 128
            'taxCalculationMode' => [static::TYPE => 'string'],
83
        ];
84
    }
85
86
    /**
87
     * @param string $currency
88
     * @param Context|callable $context
89
     * @return CartDraft
90
     */
91 128
    public static function ofCurrency($currency, $context = null)
92
    {
93 128
        $draft = static::of($context);
94 128
        return $draft->setCurrency($currency);
95
    }
96
}
97