Passed
Branch feature/ECO-808-scrutinizer (bde35b)
by Andrey
07:45
created

AbstractAdapter::getAmount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
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\Adapter;
9
10
use Generated\Shared\Transfer\AmazonpayCallTransfer;
11
use PayWithAmazon\ClientInterface;
12
use SprykerEco\Zed\Amazonpay\Business\Api\Converter\ResponseParserConverterInterface;
13
use SprykerEco\Zed\Amazonpay\Dependency\Facade\AmazonpayToMoneyInterface;
14
15
abstract class AbstractAdapter implements CallAdapterInterface
16
{
17
18
    const AMAZON_AUTHORIZATION_ID = 'amazon_authorization_id';
19
    const AMAZON_ORDER_REFERENCE_ID = 'amazon_order_reference_id';
20
    const AMAZON_ADDRESS_CONSENT_TOKEN = 'address_consent_token';
21
    const AMAZON_AMOUNT = 'amount';
22
    const AMAZON_CAPTURE_ID = 'amazon_capture_id';
23
    const AMAZON_REFUND_ID = 'amazon_refund_id';
24
25
    /**
26
     * @var \PayWithAmazon\Client
27
     */
28
    protected $client;
29
30
    /**
31
     * @var \SprykerEco\Zed\Amazonpay\Dependency\Facade\AmazonpayToMoneyInterface
32
     */
33
    protected $moneyFacade;
34
35
    /**
36
     * @var \SprykerEco\Zed\Amazonpay\Business\Api\Converter\ResponseParserConverterInterface
37
     */
38
    protected $converter;
39
40
    /**
41
     * @param \PayWithAmazon\ClientInterface $client
42
     * @param \SprykerEco\Zed\Amazonpay\Business\Api\Converter\ResponseParserConverterInterface $converter
43
     * @param \SprykerEco\Zed\Amazonpay\Dependency\Facade\AmazonpayToMoneyInterface $moneyFacade
44
     */
45
    public function __construct(
46
        ClientInterface $client,
47
        ResponseParserConverterInterface $converter,
48
        AmazonpayToMoneyInterface $moneyFacade
49
    ) {
50
        $this->client = $client;
0 ignored issues
show
Documentation Bug introduced by
$client is of type PayWithAmazon\ClientInterface, but the property $client was declared to be of type PayWithAmazon\Client. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
51
        $this->converter = $converter;
52
        $this->moneyFacade = $moneyFacade;
53
    }
54
55
    /**
56
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
57
     *
58
     * @return float
59
     */
60
    protected function getAmount(AmazonpayCallTransfer $amazonpayCallTransfer)
61
    {
62
        return $this->moneyFacade->convertIntegerToDecimal(
63
            $amazonpayCallTransfer->getRequestedAmount()
64
        );
65
    }
66
67
}
68