AbstractCustomerMapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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\Inxmail\Business\Mapper\Customer;
9
10
use Generated\Shared\Transfer\CustomerTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\CustomerTransfer 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\InxmailRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\InxmailRequestTransfer 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
use SprykerEco\Zed\Inxmail\Dependency\Facade\InxmailToLocaleFacadeInterface;
13
use SprykerEco\Zed\Inxmail\InxmailConfig;
14
15
abstract class AbstractCustomerMapper implements CustomerMapperInterface
16
{
17
    protected const LOGIN_URL = '/login';
18
19
    /**
20
     * @var \SprykerEco\Zed\Inxmail\InxmailConfig
21
     */
22
    protected $config;
23
24
    /**
25
     * @var \SprykerEco\Zed\Inxmail\Dependency\Facade\InxmailToLocaleFacadeInterface
26
     */
27
    protected $localeFacade;
28
29
    /**
30
     * @param \SprykerEco\Zed\Inxmail\InxmailConfig $config
31
     * @param \SprykerEco\Zed\Inxmail\Dependency\Facade\InxmailToLocaleFacadeInterface $localeFacade
32
     */
33
    public function __construct(InxmailConfig $config, InxmailToLocaleFacadeInterface $localeFacade)
34
    {
35
        $this->config = $config;
36
        $this->localeFacade = $localeFacade;
37
    }
38
39
    /**
40
     * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
41
     *
42
     * @return \Generated\Shared\Transfer\InxmailRequestTransfer
43
     */
44
    public function map(CustomerTransfer $customerTransfer): InxmailRequestTransfer
45
    {
46
        $inxmailRequestTransfer = new InxmailRequestTransfer();
47
        $inxmailRequestTransfer->setEvent($this->getEvent());
48
        $inxmailRequestTransfer->setTransactionId(uniqid('customer_'));
49
        $inxmailRequestTransfer->setPayload($this->getPayload($customerTransfer));
50
51
        return $inxmailRequestTransfer;
52
    }
53
54
    /**
55
     * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
56
     *
57
     * @return array
58
     */
59
    protected function getPayload(CustomerTransfer $customerTransfer): array
60
    {
61
        return [
62
            'Customer' => [
63
                'LoginUrl' => $this->config->getHostYves() . static::LOGIN_URL,
64
                'ResetLink' => $customerTransfer->getRestorePasswordLink(),
65
                'Mail' => $customerTransfer->getEmail(),
66
                'Salutation' => $customerTransfer->getSalutation(),
67
                'Firstname' => $customerTransfer->getFirstName(),
68
                'Lastname' => $customerTransfer->getLastName(),
69
                'Id' => $customerTransfer->getIdCustomer(),
70
                'Language' => $customerTransfer->getLocale() ? $customerTransfer->getLocale()->getLocaleName() : $this->localeFacade->getCurrentLocaleName(),
71
            ],
72
            'Shop' => [
73
                'ShopLocale' => $this->localeFacade->getCurrentLocaleName(),
74
                'ShopUrl' => $this->config->getHostYves(),
75
            ],
76
        ];
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    abstract protected function getEvent(): string;
83
}
84