CreatePaymentCallEntity   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 30
c 1
b 0
f 0
dl 0
loc 90
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setCart() 0 9 5
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           getChannel()
23
 * @method float            getAmount()
24
 * @method float            getFee()
25
 * @method string           getOrderId()
26
 * @method string           getCurrency()
27
 * @method CartItemEntity[] getCart()
28
 * @method string           getSalutation()
29
 * @method string           getFirstName()
30
 * @method string           getLastName()
31
 * @method string           getStreet()
32
 * @method string           getZip()
33
 * @method string           getCity()
34
 * @method string           getRegion()
35
 * @method string           getCountry()
36
 * @method string           getPhone()
37
 * @method string           getEmail()
38
 * @method string           getSuccessUrl()
39
 * @method string           getFailureUrl()
40
 * @method string           getCancelUrl()
41
 * @method string           getNoticeUrl()
42
 * @method string           getPendingUrl()
43
 * @method string           getCustomerRedirectUrl()
44
 * @method string           getXFrameHost()
45
 * @method array            getPayments()
46
 * @method string           getType()
47
 * @method self             setChannel(string $name)
48
 * @method self             setAmount(float $amount)
49
 * @method self             setFee(float $fee)
50
 * @method self             setOrderId(string $orderId)
51
 * @method self             setCurrency(string $currency)
52
 * @method self             setSalutation(string $salutation)
53
 * @method self             setFirstName(string $firstName)
54
 * @method self             setLastName(string $lastName)
55
 * @method self             setStreet(string $street)
56
 * @method self             setZip(string $zip)
57
 * @method self             setCity(string $city)
58
 * @method self             setRegion(string $region)
59
 * @method self             setCountry(string $country)
60
 * @method self             setPhone(string $phone)
61
 * @method self             setEmail(string $email)
62
 * @method self             setSuccessUrl(string $successUrl)
63
 * @method self             setFailureUrl(string $failureUrl)
64
 * @method self             setCancelUrl(string $cancelUrl)
65
 * @method self             setNoticeUrl(string $noticeUrl)
66
 * @method self             setPendingUrl(string $pendingUrl)
67
 * @method self             setCustomerRedirectUrl(string $url)
68
 * @method self             setXFrameHost(string $xFrameHost)
69
 * @method self             setPayments(array $payments)
70
 * @method self             setType(string $type)
71
 *
72
 * @SuppressWarnings(PHPMD.StaticAccess)
73
 * @SuppressWarnings(PHPMD.TooManyFields)
74
 */
75
class CreatePaymentCallEntity extends CallEntity
76
{
77
    /** @var string $channel */
78
    protected $channel;
79
80
    /** @var float $amount */
81
    protected $amount;
82
83
    /** @var float $fee */
84
    protected $fee;
85
86
    /** @var string $orderId */
87
    protected $orderId;
88
89
    /** @var string $currency */
90
    protected $currency;
91
92
    /** @var CartItemEntity[] $cart */
93
    protected $cart;
94
95
    /** @var string $salutation */
96
    protected $salutation;
97
98
    /** @var string $firstName */
99
    protected $firstName;
100
101
    /** @var string $lastName */
102
    protected $lastName;
103
104
    /** @var string $street */
105
    protected $street;
106
107
    /** @var string $zip */
108
    protected $zip;
109
110
    /** @var string $city */
111
    protected $city;
112
113
    /** @var string $region */
114
    protected $region;
115
116
    /** @var string $country */
117
    protected $country;
118
119
    /** @var string $phone */
120
    protected $phone;
121
122
    /** @var string $email */
123
    protected $email;
124
125
    /** @var string $successUrl */
126
    protected $successUrl;
127
128
    /** @var string $failureUrl */
129
    protected $failureUrl;
130
131
    /** @var string $cancelUrl */
132
    protected $cancelUrl;
133
134
    /** @var string $noticeUrl */
135
    protected $noticeUrl;
136
137
    /** @var string $pendingUrl */
138
    protected $pendingUrl;
139
140
    /** @var string $xFrameHost */
141
    protected $xFrameHost;
142
143
    /** @var array $payments */
144
    protected $payments;
145
146
    /** @var string $type */
147
    protected $type;
148
149
    /**
150
     * Sets Cart
151
     *
152
     * @param array|string $cart
153
     *
154
     * @throws \Exception
155
     */
156
    public function setCart($cart)
157
    {
158
        if (is_string($cart)) {
159
            $cart = StringHelper::jsonDecode($cart);
160
        }
161
162
        if ($cart && is_array($cart)) {
163
            foreach ($cart as $item) {
164
                $this->cart[] = new CartItemEntity($item);
165
            }
166
        }
167
    }
168
}
169