Completed
Push — feature/ECO-1185-eco-ci ( 4da4ac...5d4add )
by Andrey
13:41 queued 10:25
created

updateNameData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Apache OSL-2
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\AmazonPay\Business\Api\Converter;
9
10
use Generated\Shared\Transfer\AmazonpayResponseTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...azonpayResponseTransfer 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\CustomerTransfer;
1 ignored issue
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...
12
13
class ObtainProfileInformationConverter extends AbstractArrayConverter
14
{
15
    const NAME = 'name';
16
    const EMAIL = 'email';
17
18
    /**
19
     * @param array $response
20
     *
21
     * @return \Generated\Shared\Transfer\AmazonpayResponseTransfer
22
     */
23
    public function convert(array $response)
24
    {
25
        $responseTransfer = new AmazonpayResponseTransfer();
26
        $customerTransfer = new CustomerTransfer();
27
28
        $this->extractName($response, $customerTransfer);
29
        $this->extractEmail($response, $customerTransfer);
30
31
        $responseTransfer->setCustomer($customerTransfer);
32
33
        return $responseTransfer;
34
    }
35
36
    /**
37
     * @param array $response
38
     * @param \Generated\Shared\Transfer\CustomerTransfer $responseTransfer
39
     *
40
     * @return void
41
     */
42
    protected function extractName(array $response, CustomerTransfer $responseTransfer)
43
    {
44
        if (!empty($response[self::NAME])) {
45
            $this->updateNameData($responseTransfer, $response[self::NAME]);
46
        }
47
    }
48
49
    /**
50
     * @param \Generated\Shared\Transfer\CustomerTransfer $transfer
51
     * @param string $name
52
     *
53
     * @return \Generated\Shared\Transfer\CustomerTransfer
54
     */
55
    protected function updateNameData(CustomerTransfer $transfer, $name)
56
    {
57
        $names = $this->getNameData($name);
58
59
        $transfer->setFirstName($names[0]);
60
        $transfer->setLastName($names[1]);
61
62
        return $transfer;
63
    }
64
65
    /**
66
     * @param array $response
67
     * @param \Generated\Shared\Transfer\CustomerTransfer $responseTransfer
68
     *
69
     * @return void
70
     */
71
    protected function extractEmail(array $response, CustomerTransfer $responseTransfer)
72
    {
73
        if (!empty($response[self::EMAIL])) {
74
            $responseTransfer->setEmail($response[self::EMAIL]);
75
        }
76
    }
77
}
78