DeliveryCustomerMapper::map()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 10
c 1
b 1
f 0
nc 1
nop 1
dl 0
loc 13
rs 9.9332
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\ArvatoRss\Business\Api\Mapper\Aspect;
9
10
use Generated\Shared\Transfer\AddressTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\AddressTransfer 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\ArvatoRssCustomerAddressTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...CustomerAddressTransfer 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 Generated\Shared\Transfer\ArvatoRssDeliveryCustomerTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...eliveryCustomerTransfer 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...
13
use Generated\Shared\Transfer\DeliveryCustomerMapperTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...yCustomerMapperTransfer 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...
14
use SprykerEco\Service\ArvatoRss\Iso3166ConverterServiceInterface;
15
16
class DeliveryCustomerMapper implements DeliveryCustomerMapperInterface
17
{
18
    /**
19
     * @var \SprykerEco\Service\ArvatoRss\Iso3166ConverterServiceInterface
20
     */
21
    protected $iso3166Converter;
22
23
    /**
24
     * @param \SprykerEco\Service\ArvatoRss\Iso3166ConverterServiceInterface $iso3166Converter
25
     */
26
    public function __construct(
27
        Iso3166ConverterServiceInterface $iso3166Converter
28
    ) {
29
        $this->iso3166Converter = $iso3166Converter;
30
    }
31
32
    /**
33
     * @param \Generated\Shared\Transfer\DeliveryCustomerMapperTransfer $deliveryCustomerMapperTransfer
34
     *
35
     * @return \Generated\Shared\Transfer\ArvatoRssDeliveryCustomerTransfer
36
     */
37
    public function map(DeliveryCustomerMapperTransfer $deliveryCustomerMapperTransfer)
38
    {
39
        $deliveryCustomerTransfer = new ArvatoRssDeliveryCustomerTransfer();
40
        $deliveryAddressTransfer = $deliveryCustomerMapperTransfer->getDeliveryAddress();
41
        $customerAddressTransfer = $this->prepareCustomerAddressTransfer($deliveryAddressTransfer);
42
        $deliveryCustomerTransfer->setAddress($customerAddressTransfer);
43
        $deliveryCustomerTransfer->setFirstName($deliveryAddressTransfer->getFirstName());
44
        $deliveryCustomerTransfer->setLastName($deliveryAddressTransfer->getLastName());
45
        $deliveryCustomerTransfer->setSalutation(strtoupper($deliveryAddressTransfer->getSalutation()));
46
        $deliveryCustomerTransfer->setEmail($deliveryCustomerMapperTransfer->getEmail());
47
        $deliveryCustomerTransfer->setTelephoneNumber($deliveryAddressTransfer->getPhone());
48
49
        return $deliveryCustomerTransfer;
50
    }
51
52
    /**
53
     * @param \Generated\Shared\Transfer\AddressTransfer $addressTransfer
54
     *
55
     * @return \Generated\Shared\Transfer\ArvatoRssCustomerAddressTransfer
56
     */
57
    protected function prepareCustomerAddressTransfer(AddressTransfer $addressTransfer)
58
    {
59
        $customerAddressTransfer = new ArvatoRssCustomerAddressTransfer();
60
        $customerAddressTransfer->setCountry($this->iso3166Converter->iso2ToNumeric($addressTransfer->getIso2Code()));
61
        $customerAddressTransfer->setCity($addressTransfer->getCity());
62
        $customerAddressTransfer->setStreet($addressTransfer->getAddress1());
63
        $customerAddressTransfer->setStreetNumber($addressTransfer->getAddress2());
64
        $customerAddressTransfer->setZipCode($addressTransfer->getZipCode());
65
        $customerAddressTransfer->setStreetNumberAdditional($addressTransfer->getAddress3());
66
67
        return $customerAddressTransfer;
68
    }
69
}
70