Passed
Pull Request — develop (#533)
by Barbara
21:04
created

PaymentDraft::ofKeyExternalIdAndAmountPlanned()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 1
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Payment;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Model\Common\JsonObject;
10
use Commercetools\Core\Model\Customer\CustomerReference;
11
use Commercetools\Core\Model\Common\Money;
12
use Commercetools\Core\Model\Common\DateTimeDecorator;
13
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft;
14
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraftCollection;
15
use DateTime;
16
17
/**
18
 * @package Commercetools\Core\Model\Payment
19
 * @link https://docs.commercetools.com/http-api-projects-payments.html#paymentdraft
20
 * @method CustomerReference getCustomer()
21
 * @method PaymentDraft setCustomer(CustomerReference $customer = null)
22
 * @method string getInterfaceId()
23
 * @method PaymentDraft setInterfaceId(string $interfaceId = null)
24
 * @method Money getAmountPlanned()
25
 * @method PaymentDraft setAmountPlanned(Money $amountPlanned = null)
26
 * @method PaymentMethodInfo getPaymentMethodInfo()
27
 * @method PaymentDraft setPaymentMethodInfo(PaymentMethodInfo $paymentMethodInfo = null)
28
 * @method CustomFieldObjectDraft getCustom()
29
 * @method PaymentDraft setCustom(CustomFieldObjectDraft $custom = null)
30
 * @method PaymentStatus getPaymentStatus()
31
 * @method PaymentDraft setPaymentStatus(PaymentStatus $paymentStatus = null)
32
 * @method TransactionCollection getTransactions()
33
 * @method PaymentDraft setTransactions(TransactionCollection $transactions = null)
34
 * @method CustomFieldObjectDraftCollection getInterfaceInteractions()
35
 * @method PaymentDraft setInterfaceInteractions(CustomFieldObjectDraftCollection $interfaceInteractions = null)
36
 * @method string getKey()
37
 * @method PaymentDraft setKey(string $key = null)
38
 * @method string getAnonymousId()
39
 * @method PaymentDraft setAnonymousId(string $anonymousId = null)
40
 */
41
class PaymentDraft extends JsonObject
42
{
43 30
    public function fieldDefinitions()
44
    {
45
        return [
46 30
            'key' => [static::TYPE => 'string'],
47 30
            'customer' => [static::TYPE => CustomerReference::class],
48 30
            'anonymousId' => [static::TYPE => 'string'],
49 30
            'externalId' => [static::TYPE => 'string'],
50 30
            'interfaceId' => [static::TYPE => 'string'],
51 30
            'amountPlanned' => [static::TYPE => Money::class],
52 30
            'amountAuthorized' => [static::TYPE => Money::class],
53
            'authorizedUntil' => [
54 30
                static::TYPE => DateTime::class,
55 30
                static::DECORATOR => DateTimeDecorator::class
56
            ],
57 30
            'amountPaid' => [static::TYPE => Money::class],
58 30
            'amountRefunded' => [static::TYPE => Money::class],
59 30
            'paymentMethodInfo' => [static::TYPE => PaymentMethodInfo::class],
60 30
            'custom' => [static::TYPE => CustomFieldObjectDraft::class],
61 30
            'paymentStatus' => [static::TYPE => PaymentStatus::class],
62 30
            'transactions' => [static::TYPE => TransactionCollection::class],
63
            'interfaceInteractions' => [
64 30
                static::TYPE => CustomFieldObjectDraftCollection::class
65
            ],
66
        ];
67
    }
68
69
    /**
70
     * @deprecated
71
     * @return string
72
     */
73
    public function getExternalId()
74
    {
75
        return parent::getExternalId();
0 ignored issues
show
introduced by
The method getExternalId() does not exist on Commercetools\Core\Model\Common\JsonObject. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

75
        return parent::/** @scrutinizer ignore-call */ getExternalId();
Loading history...
76
    }
77
78
    /**
79
     * @deprecated use setKey() instead
80
     * @param string $externalId
81
     * @return static
82
     */
83 28
    public function setExternalId($externalId = null)
84
    {
85 28
        return parent::setExternalId($externalId);
0 ignored issues
show
introduced by
The method setExternalId() does not exist on Commercetools\Core\Model\Common\JsonObject. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

85
        return parent::/** @scrutinizer ignore-call */ setExternalId($externalId);
Loading history...
86
    }
87
88
    /**
89
     * @deprecated
90
     * @return Money
91
     */
92
    public function getAmountAuthorized()
93
    {
94
        return parent::getAmountAuthorized();
0 ignored issues
show
introduced by
The method getAmountAuthorized() does not exist on Commercetools\Core\Model\Common\JsonObject. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

94
        return parent::/** @scrutinizer ignore-call */ getAmountAuthorized();
Loading history...
95
    }
96
97
    /**
98
     * @deprecated
99
     * @param Money $amountAuthorized
100
     * @return static
101
     */
102
    public function setAmountAuthorized(Money $amountAuthorized = null)
103
    {
104
        return parent::setAmountAuthorized($amountAuthorized);
0 ignored issues
show
introduced by
The method setAmountAuthorized() does not exist on Commercetools\Core\Model\Common\JsonObject. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

104
        return parent::/** @scrutinizer ignore-call */ setAmountAuthorized($amountAuthorized);
Loading history...
105
    }
106
107
    /**
108
     * @deprecated
109
     * @return Money
110
     */
111
    public function getAmountPaid()
112
    {
113
        return parent::getAmountPaid();
0 ignored issues
show
introduced by
The method getAmountPaid() does not exist on Commercetools\Core\Model\Common\JsonObject. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

113
        return parent::/** @scrutinizer ignore-call */ getAmountPaid();
Loading history...
114
    }
115
116
    /**
117
     * @deprecated
118
     * @param Money $amountPaid
119
     * @return static
120
     */
121
    public function setAmountPaid(Money $amountPaid = null)
122
    {
123
        return parent::setAmountPaid($amountPaid);
0 ignored issues
show
introduced by
The method setAmountPaid() does not exist on Commercetools\Core\Model\Common\JsonObject. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

123
        return parent::/** @scrutinizer ignore-call */ setAmountPaid($amountPaid);
Loading history...
124
    }
125
126
    /**
127
     * @deprecated
128
     * @return Money
129
     */
130
    public function getAmountRefunded()
131
    {
132
        return parent::getAmountRefunded();
0 ignored issues
show
introduced by
The method getAmountRefunded() does not exist on Commercetools\Core\Model\Common\JsonObject. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

132
        return parent::/** @scrutinizer ignore-call */ getAmountRefunded();
Loading history...
133
    }
134
135
    /**
136
     * @deprecated
137
     * @param Money $amountRefunded
138
     * @return static
139
     */
140
    public function setAmountRefunded(Money $amountRefunded = null)
141
    {
142
        return parent::setAmountRefunded($amountRefunded);
0 ignored issues
show
introduced by
The method setAmountRefunded() does not exist on Commercetools\Core\Model\Common\JsonObject. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

142
        return parent::/** @scrutinizer ignore-call */ setAmountRefunded($amountRefunded);
Loading history...
143
    }
144
145
    /**
146
     * @deprecated
147
     * @return Money
148
     */
149
    public function getAuthorizedUntil()
150
    {
151
        return parent::getAuthorizedUntil();
0 ignored issues
show
introduced by
The method getAuthorizedUntil() does not exist on Commercetools\Core\Model\Common\JsonObject. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

151
        return parent::/** @scrutinizer ignore-call */ getAuthorizedUntil();
Loading history...
152
    }
153
154
    /**
155
     * @deprecated
156
     * @param Money $amountUntil
157
     * @return static
158
     */
159
    public function setAuthorizedUntil(Money $amountUntil = null)
160
    {
161
        return parent::setAuthorizedUntil($amountUntil);
0 ignored issues
show
introduced by
The method setAuthorizedUntil() does not exist on Commercetools\Core\Model\Common\JsonObject. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

161
        return parent::/** @scrutinizer ignore-call */ setAuthorizedUntil($amountUntil);
Loading history...
162
    }
163
164
    /**
165
     * @param Money $amountPlanned
166
     * @param Context|callable $context
167
     * @return PaymentDraft
168
     */
169
    public static function ofAmountPlanned(Money $amountPlanned, $context = null)
170
    {
171
        return static::of($context)->setAmountPlanned($amountPlanned);
172
    }
173
174
    /**
175
     * @param string $key
176
     * @param string $externalId
177
     * @param Money $amountPlanned
178
     * @param Context|callable $context
179
     * @return PaymentDraft
180
     */
181 21
    public static function ofKeyExternalIdAndAmountPlanned($key, $externalId, Money $amountPlanned, $context = null)
182
    {
183 21
        return static::of($context)->setKey($key)->setExternalId($externalId)->setAmountPlanned($amountPlanned);
0 ignored issues
show
Deprecated Code introduced by
The function Commercetools\Core\Model...tDraft::setExternalId() has been deprecated: use setKey() instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

183
        return /** @scrutinizer ignore-deprecated */ static::of($context)->setKey($key)->setExternalId($externalId)->setAmountPlanned($amountPlanned);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

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

Loading history...
184
    }
185
186
    /**
187
     * @param string $key
188
     * @param string $externalId
189
     * @param Money $amountPlanned
190
     * @param PaymentMethodInfo $paymentMethodInfo
191
     * @param Context|callable $context
192
     * @return PaymentDraft
193
     */
194 7
    public static function ofKeyExternalIdAmountPlannedAndPaymentMethodInfo(
195
        $key,
196
        $externalId,
197
        Money $amountPlanned,
198
        PaymentMethodInfo $paymentMethodInfo,
199
        $context = null
200
    ) {
201 7
        return static::of($context)
0 ignored issues
show
Deprecated Code introduced by
The function Commercetools\Core\Model...tDraft::setExternalId() has been deprecated: use setKey() instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

201
        return /** @scrutinizer ignore-deprecated */ static::of($context)

This function has been deprecated. The supplier of the function has supplied an explanatory message.

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

Loading history...
202 7
            ->setKey($key)
203 7
            ->setExternalId($externalId)
204 7
            ->setAmountPlanned($amountPlanned)
205 7
            ->setPaymentMethodInfo($paymentMethodInfo);
206
    }
207
}
208