Passed
Branch php-scrutinizer (0ac9d8)
by Jens
09:19
created

CartDraft::fieldDefinitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 21
cts 21
cp 1
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 21
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author @jenschude <[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
use Commercetools\Core\Model\TaxCategory\ExternalTaxRateDraft;
16
17
/**
18
 * @package Commercetools\Core\Model\Cart
19
 * @link https://docs.commercetools.com/http-api-projects-carts.html#cartdraft
20
 * @method string getCurrency()
21
 * @method string getCustomerId()
22
 * @method string getCountry()
23
 * @method string getInventoryMode()
24
 * @method CartDraft setCurrency(string $currency = null)
25
 * @method CartDraft setCustomerId(string $customerId = null)
26
 * @method CartDraft setCountry(string $country = null)
27
 * @method CartDraft setInventoryMode(string $inventoryMode = null)
28
 * @method CustomFieldObjectDraft getCustom()
29
 * @method CartDraft setCustom(CustomFieldObjectDraft $custom = null)
30
 * @method string getCustomerEmail()
31
 * @method CartDraft setCustomerEmail(string $customerEmail = null)
32
 * @method LineItemDraftCollection getLineItems()
33
 * @method CartDraft setLineItems(LineItemDraftCollection $lineItems = null)
34
 * @method Address getShippingAddress()
35
 * @method CartDraft setShippingAddress(Address $shippingAddress = null)
36
 * @method Address getBillingAddress()
37
 * @method CartDraft setBillingAddress(Address $billingAddress = null)
38
 * @method ShippingMethodReference getShippingMethod()
39
 * @method CartDraft setShippingMethod(ShippingMethodReference $shippingMethod = null)
40
 * @method CustomLineItemDraftCollection getCustomLineItems()
41
 * @method CartDraft setCustomLineItems(CustomLineItemDraftCollection $customLineItems = null)
42
 * @method string getTaxMode()
43
 * @method CartDraft setTaxMode(string $taxMode = null)
44
 * @method string getAnonymousId()
45
 * @method CartDraft setAnonymousId(string $anonymousId = null)
46
 * @method string getLocale()
47
 * @method string getTaxRoundingMode()
48
 * @method CartDraft setTaxRoundingMode(string $taxRoundingMode = null)
49
 * @method int getDeleteDaysAfterLastModification()
50
 * @method CartDraft setDeleteDaysAfterLastModification(int $deleteDaysAfterLastModification = null)
51
 * @method CustomerGroupReference getCustomerGroup()
52
 * @method CartDraft setCustomerGroup(CustomerGroupReference $customerGroup = null)
53
 * @method string getOrigin()
54
 * @method CartDraft setOrigin(string $origin = null)
55
 * @method string getTaxCalculationMode()
56
 * @method CartDraft setTaxCalculationMode(string $taxCalculationMode = null)
57
 * @method ExternalTaxRateDraft getExternalTaxRateForShippingMethod()
58
 * @method CartDraft setExternalTaxRateForShippingMethod(ExternalTaxRateDraft $externalTaxRateForShippingMethod = null)
59
 */
60
class CartDraft extends JsonObject
61
{
62
    use LocaleTrait;
63
64 130
    public function fieldDefinitions()
65
    {
66
        return [
67 130
            'currency' => [static::TYPE => 'string'],
68 130
            'customerId' => [static::TYPE => 'string'],
69 130
            'customerEmail' => [static::TYPE => 'string'],
70 130
            'country' => [static::TYPE => 'string'],
71 130
            'inventoryMode' => [static::TYPE => 'string'],
72 130
            'lineItems' => [static::TYPE => LineItemDraftCollection::class],
73 130
            'customLineItems' => [static::TYPE => CustomLineItemDraftCollection::class],
74 130
            'shippingAddress' => [static::TYPE => Address::class],
75 130
            'billingAddress' => [static::TYPE => Address::class],
76 130
            'shippingMethod' => [static::TYPE => ShippingMethodReference::class],
77 130
            'custom' => [static::TYPE => CustomFieldObjectDraft::class],
78 130
            'taxMode' => [static::TYPE => 'string'],
79 130
            'anonymousId' => [static::TYPE => 'string'],
80 130
            'locale' => [static::TYPE => 'string'],
81 130
            'taxRoundingMode' => [static::TYPE => 'string'],
82 130
            'deleteDaysAfterLastModification' => [static::TYPE => 'int'],
83 130
            'customerGroup' => [static::TYPE => CustomerGroupReference::class],
84 130
            'origin' => [static::TYPE => 'string'],
85 130
            'taxCalculationMode' => [static::TYPE => 'string'],
86 130
            'externalTaxRateForShippingMethod' => [static::TYPE => ExternalTaxRateDraft::class]
87
        ];
88
    }
89
90
    /**
91
     * @param string $currency
92
     * @param Context|callable $context
93
     * @return CartDraft
94
     */
95 129
    public static function ofCurrency($currency, $context = null)
96
    {
97 129
        $draft = static::of($context);
98 129
        return $draft->setCurrency($currency);
99
    }
100
}
101