Passed
Push — master ( bfa84d...d19f7c )
by payever
02:58
created

CreatePaymentV2CallEntity::setAddress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * PHP version 5.4 and 8
5
 *
6
 * @category  MessageEntity
7
 * @package   Payever\Payments
8
 * @author    payever GmbH <[email protected]>
9
 * @copyright 2017-2021 payever GmbH
10
 * @license   MIT <https://opensource.org/licenses/MIT>
11
 * @link      https://docs.payever.org/shopsystems/api/getting-started
12
 */
13
14
namespace Payever\ExternalIntegration\Payments\Http\MessageEntity;
15
16
use Payever\ExternalIntegration\Core\Helper\StringHelper;
17
use Payever\ExternalIntegration\Core\Http\MessageEntity\CallEntity;
18
19
/**
20
 * This class represents Create Payment Call Entity
21
 *
22
 * @method string           getStatus()
23
 * @method string           getId()
24
 * @method \DateTime|false      getCreatedAt()
25
 * @method string           getChannel()
26
 * @method float            getAmount()
27
 * @method float            getPaymentFee()
28
 * @method float            getDeliveryFee()
29
 * @method string           getReference()
30
 * @method string           getCurrency()
31
 * @method CartItemEntity[] getCart()
32
 * @method AddressEntity    getAddress()
33
 * @method AddressEntity    getShippingAddress()
34
 * @method string           getCustomerEmail()
35
 * @method float            getTotal()
36
 * @method float            getDownPayment()
37
 * @method string           getSuccessUrl()
38
 * @method string           getFailureUrl()
39
 * @method string           getCancelUrl()
40
 * @method string           getNoticeUrl()
41
 * @method string           getPendingUrl()
42
 * @method string           getPaymentType()
43
 * @method self             setStatus(string $status)
44
 * @method self             setId(string $id)
45
 * @method self             setChannel(string $name)
46
 * @method self             setAmount(float $amount)
47
 * @method self             setPaymentFee(float $paymentFee)
48
 * @method self             setDeliveryFee(float $deliveryFee)
49
 * @method self             setReference(string $reference)
50
 * @method self             setCurrency(string $currency)
51
 * @method self             setCustomerEmail(string $email)
52
 * @method self             setTotal(float $total)
53
 * @method self             setDownPayment(float $downPayment)
54
 * @method self             setSuccessUrl(string $successUrl)
55
 * @method self             setFailureUrl(string $failureUrl)
56
 * @method self             setCancelUrl(string $cancelUrl)
57
 * @method self             setNoticeUrl(string $noticeUrl)
58
 * @method self             setPendingUrl(string $pendingUrl)
59
 * @method self             setPaymentType(string $paymentType)
60
 *
61
 * @SuppressWarnings(PHPMD.StaticAccess)
62
 * @SuppressWarnings(PHPMD.TooManyFields)
63
 */
64
class CreatePaymentV2CallEntity extends CallEntity
65
{
66
    /** @var string $status */
67
    protected $status;
68
69
    /** @var string $id */
70
    protected $id;
71
72
    /** @var \DateTime|bool $createdAt */
73
    protected $createdAt;
74
75
    /** @var string $channel */
76
    protected $channel;
77
78
    /** @var float $amount */
79
    protected $amount;
80
81
    /** @var float $paymentFee */
82
    protected $paymentFee;
83
84
    /** @var float $fee */
85
    protected $deliveryFee;
86
87
    /** @var string $reference */
88
    protected $reference;
89
90
    /** @var string $currency */
91
    protected $currency;
92
93
    /** @var CartItemEntity[] $cart */
94
    protected $cart;
95
96
    /** @var AddressEntity $address */
97
    protected $address;
98
99
    /** @var AddressEntity $shippingAddress */
100
    protected $shippingAddress;
101
102
    /** @var string $customerEmail */
103
    protected $customerEmail;
104
105
    /** @var float $total */
106
    protected $total;
107
108
    /** @var float $downPayment */
109
    protected $downPayment;
110
111
    /** @var string $successUrl */
112
    protected $successUrl;
113
114
    /** @var string $failureUrl */
115
    protected $failureUrl;
116
117
    /** @var string $cancelUrl */
118
    protected $cancelUrl;
119
120
    /** @var string $noticeUrl */
121
    protected $noticeUrl;
122
123
    /** @var string $pendingUrl */
124
    protected $pendingUrl;
125
126
    /** @var string $paymentType */
127
    protected $paymentType;
128
129
    /**
130
     * Sets Cart
131
     *
132
     * @param array|string $cart
133
     *
134
     * @throws \Exception
135
     */
136
    public function setCart($cart)
137
    {
138
        if (is_string($cart)) {
139
            $cart = StringHelper::jsonDecode($cart);
140
        }
141
142
        if ($cart && is_array($cart)) {
143
            foreach ($cart as $item) {
144
                $this->cart[] = new CartItemEntity($item);
145
            }
146
        }
147
    }
148
149
    /**
150
     * Sets Address
151
     *
152
     * @param array $address
153
     */
154
    public function setAddress($address)
155
    {
156
        $this->address = new AddressEntity($address);
157
    }
158
159
    /**
160
     * Sets Shipping Address
161
     *
162
     * @param array $shippingAddress
163
     */
164
    public function setShippingAddress($shippingAddress)
165
    {
166
        $this->shippingAddress = new AddressEntity($shippingAddress);
167
    }
168
169
    /**
170
     * Sets Created At
171
     *
172
     * @param string $createdAt
173
     */
174
    public function setCreatedAt($createdAt)
175
    {
176
        $this->createdAt = date_create($createdAt);
177
    }
178
}
179