Customer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 45
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildData() 0 30 3
A getRootTag() 0 3 1
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Ratepay\Business\Api\Builder;
9
10
use SprykerEco\Zed\Ratepay\Business\Api\Constants;
11
12
/**
13
 * Class Customer
14
 * @package SprykerEco\Zed\Ratepay\Business\Api\Builder
15
 */
16
class Customer extends AbstractBuilder implements CustomerInterface
17
{
18
    public const ROOT_TAG = 'customer';
19
20
    /**
21
     * @return array
22
     */
23
    public function buildData()
24
    {
25
        $customerData = [
26
            'first-name' => $this->requestTransfer->getCustomer()->getFirstName(),
27
            'last-name' => $this->requestTransfer->getCustomer()->getLastName(),
28
            'gender' => $this->requestTransfer->getCustomer()->getGender(),
29
            'date-of-birth' => $this->requestTransfer->getCustomer()->getDob(),
30
            'ip-address' => $this->requestTransfer->getCustomer()->getIpAddress(),
31
            'contacts' => [
32
                'email' => $this->requestTransfer->getCustomer()->getEmail(),
33
                'phone' => [
34
                    'direct-dial' => $this->requestTransfer->getCustomer()->getPhone(),
35
                ],
36
            ],
37
            'addresses' => [
38
                (new Address($this->requestTransfer, Constants::REQUEST_MODEL_ADDRESS_TYPE_BILLING)),
39
                (new Address($this->requestTransfer, Constants::REQUEST_MODEL_ADDRESS_TYPE_DELIVERY)),
40
            ],
41
            'customer-allow-credit-inquiry' => $this->requestTransfer->getCustomer()->getAllowCreditInquiry(),
42
        ];
43
        if (strlen($this->requestTransfer->getCustomer()->getCompany())) {
44
            $customerData['company-name'] = $this->requestTransfer->getCustomer()->getCompany();
45
        }
46
47
        if ($this->requestTransfer->getBankAccount() !== null) {
48
            $bankAccountBuilder = new BankAccount($this->requestTransfer);
49
            $customerData[$bankAccountBuilder->getRootTag()] = $bankAccountBuilder;
50
        }
51
52
        return $customerData;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getRootTag()
59
    {
60
        return static::ROOT_TAG;
61
    }
62
}
63