CustomerMapper::buildPayload()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 24
c 0
b 0
f 0
rs 9.7666
cc 3
nc 4
nop 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\Episerver\Business\Mapper\Customer;
9
10
use Generated\Shared\Transfer\EpiserverRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\EpiserverRequestTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Generated\Shared\Transfer\MailTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\MailTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
13
class CustomerMapper extends AbstractCustomerMapper
14
{
15
    /**
16
     * @param \Generated\Shared\Transfer\MailTransfer $mailTransfer
17
     * @param \Generated\Shared\Transfer\EpiserverRequestTransfer $requestTransfer
18
     *
19
     * @return \Generated\Shared\Transfer\EpiserverRequestTransfer
20
     */
21
    public function mapMailTransferToEpiserverRequestTransfer(MailTransfer $mailTransfer, EpiserverRequestTransfer $requestTransfer): EpiserverRequestTransfer
22
    {
23
        $requestTransfer->setAuthorizationCode($this->config->getCustomerListAuthorizationCode());
24
        $requestTransfer->setOperationType($this->config->getOperationSendTransactionEmail());
25
        $requestTransfer->setPayload($this->buildPayload($mailTransfer));
26
27
        return $requestTransfer;
28
    }
29
30
    /**
31
     * @param \Generated\Shared\Transfer\MailTransfer $mailTransfer
32
     *
33
     * @return array
34
     */
35
    protected function buildPayload(MailTransfer $mailTransfer): array
36
    {
37
        $customerTransfer = $mailTransfer->getCustomer();
38
39
        $payload = [
40
            static::KEY_CUSTOMER_SHOP_LOCALE => $this->getLocale($customerTransfer),
41
            static::KEY_CUSTOMER_SHOP_URL => $this->config->getHostYves(),
42
            static::KEY_CUSTOMER_LOGIN_URL => $this->config->getHostYves() . static::URL_LOGIN,
43
        ];
44
45
        if ($customerTransfer !== null) {
46
            $payload[static::KEY_EMAIL] = $customerTransfer->getEmail();
47
            $payload[static::KEY_SALUTATION] = $customerTransfer->getSalutation();
48
            $payload[static::KEY_FIRST_NAME] = $customerTransfer->getFirstName();
49
            $payload[static::KEY_LAST_NAME] = $customerTransfer->getLastName();
50
            $payload[static::KEY_SPRYKER_ID] = $customerTransfer->getIdCustomer();
51
            $payload[static::KEY_CUSTOMER_RESET_LINK] = $customerTransfer->getRestorePasswordLink();
52
        }
53
54
        if ($mailTransfer->getType() !== null) {
55
            $payload[static::KEY_MAILING_ID] = $this->getMailingIdByMailType($mailTransfer->getType());
56
        }
57
58
        return $payload;
59
    }
60
}
61