Completed
Pull Request — master (#4)
by Andrey
10:46 queued 03:14
created

ObtainProfileInformationAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A call() 0 9 1
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\Adapter;
9
10
use Generated\Shared\Transfer\AmazonpayCallTransfer;
11
use PayWithAmazon\ClientInterface;
12
use SprykerEco\Zed\Amazonpay\Business\Api\Converter\ArrayConverterInterface;
13
14
class ObtainProfileInformationAdapter implements CallAdapterInterface
15
{
16
17
    /**
18
     * @var \PayWithAmazon\ClientInterface
19
     */
20
    protected $client;
21
22
    /**
23
     * @var \SprykerEco\Zed\Amazonpay\Business\Api\Converter\ArrayConverterInterface
24
     */
25
    protected $converter;
26
27
    /**
28
     * @param \PayWithAmazon\ClientInterface $client
29
     * @param \SprykerEco\Zed\Amazonpay\Business\Api\Converter\ArrayConverterInterface $converter
30
     */
31
    public function __construct(
32
        ClientInterface $client,
33
        ArrayConverterInterface $converter
34
    ) {
35
        $this->client = $client;
36
        $this->converter = $converter;
37
    }
38
39
    /**
40
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
41
     *
42
     * @return \Generated\Shared\Transfer\CustomerTransfer
43
     */
44
    public function call(AmazonpayCallTransfer $amazonpayCallTransfer)
45
    {
46
        $result = $this->client->getUserInfo($amazonpayCallTransfer->getAmazonpayPayment()->getAddressConsentToken());
47
48
        /** @var \Generated\Shared\Transfer\CustomerTransfer $customer */
49
        $customer = $this->converter->convert($result);
50
        $customer->setIsGuest(true);
51
52
        return $customer;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $customer returns the type Generated\Shared\Transfer\CustomerTransfer which is incompatible with the return type mandated by SprykerEco\Zed\Amazonpay...dapterInterface::call() of Generated\Shared\Transfe...azonpayResponseTransfer.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
53
    }
54
55
}
56