Passed
Push — master ( 78880b...ac7e2f )
by Jens
20:00 queued 13s
created

MyCartDraft::ofCurrencyAndShippingCountry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 2
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Cart;
7
8
use Commercetools\Core\Model\Common\AddressCollection;
9
use Commercetools\Core\Model\Common\Context;
10
use Commercetools\Core\Model\Common\JsonObject;
11
use Commercetools\Core\Model\Common\LocaleTrait;
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://docs.commercetools.com/http-api-projects-me-carts.html#mycartdraft
19
 * @method string getCurrency()
20
 * @method MyCartDraft setCurrency(string $currency = null)
21
 * @method string getCustomerEmail()
22
 * @method MyCartDraft setCustomerEmail(string $customerEmail = null)
23
 * @method string getCountry()
24
 * @method MyCartDraft setCountry(string $country = null)
25
 * @method string getInventoryMode()
26
 * @method MyCartDraft setInventoryMode(string $inventoryMode = null)
27
 * @method MyLineItemDraftCollection getLineItems()
28
 * @method MyCartDraft setLineItems(MyLineItemDraftCollection $lineItems = null)
29
 * @method Address getShippingAddress()
30
 * @method MyCartDraft setShippingAddress(Address $shippingAddress = null)
31
 * @method Address getBillingAddress()
32
 * @method MyCartDraft setBillingAddress(Address $billingAddress = null)
33
 * @method ShippingMethodReference getShippingMethod()
34
 * @method MyCartDraft setShippingMethod(ShippingMethodReference $shippingMethod = null)
35
 * @method CustomFieldObjectDraft getCustom()
36
 * @method MyCartDraft setCustom(CustomFieldObjectDraft $custom = null)
37
 * @method string getLocale()
38
 * @method int getDeleteDaysAfterLastModification()
39
 * @method MyCartDraft setDeleteDaysAfterLastModification(int $deleteDaysAfterLastModification = null)
40
 * @method string getTaxMode()
41
 * @method MyCartDraft setTaxMode(string $taxMode = null)
42
 * @method AddressCollection getItemShippingAddresses()
43
 * @method MyCartDraft setItemShippingAddresses(AddressCollection $itemShippingAddresses = null)
44
 */
45
class MyCartDraft extends JsonObject
46
{
47
    use LocaleTrait;
48
49 13
    public function fieldDefinitions()
50
    {
51
        return [
52 13
            'currency' => [static::TYPE => 'string'],
53 13
            'customerEmail' => [static::TYPE => 'string'],
54 13
            'country' => [static::TYPE => 'string'],
55 13
            'inventoryMode' => [static::TYPE => 'string'],
56 13
            'lineItems' => [static::TYPE => MyLineItemDraftCollection::class],
57 13
            'shippingAddress' => [static::TYPE => Address::class],
58 13
            'billingAddress' => [static::TYPE => Address::class],
59 13
            'shippingMethod' => [static::TYPE => ShippingMethodReference::class],
60 13
            'custom' => [static::TYPE => CustomFieldObjectDraft::class],
61 13
            'locale' => [static::TYPE => 'string'],
62 13
            'deleteDaysAfterLastModification' => [static::TYPE => 'int'],
63 13
            'taxMode' => [static::TYPE => 'string'],
64 13
            'itemShippingAddresses' => [static::TYPE => AddressCollection::class],
65
        ];
66
    }
67
68
    /**
69
     * @param string $currency
70
     * @param Context|callable $context
71
     * @return MyCartDraft
72
     */
73 11
    public static function ofCurrency($currency, $context = null)
74
    {
75 11
        $draft = static::of($context);
76 11
        return $draft->setCurrency($currency);
77
    }
78
79
    /**
80
     * @param string $currency
81
     * @param string $country
82
     * @param Context|callable $context
83
     * @return MyCartDraft
84
     */
85
    public static function ofCurrencyAndShippingCountry($currency, $country, $context = null)
86
    {
87
        $draft = static::of($context);
88
89
        return $draft->setCurrency($currency)
90
            ->setCountry($country)
91
            ->setShippingAddress(Address::of()->setCountry($country));
92
    }
93
}
94