Completed
Pull Request — master (#4)
by Andrey
15:48 queued 11:24
created

createShippingAddressQuoteDataUpdater()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
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\Quote;
9
10
use SprykerEco\Shared\Amazonpay\AmazonpayConfigInterface;
11
use SprykerEco\Zed\Amazonpay\Business\Api\Adapter\AdapterFactoryInterface;
12
use SprykerEco\Zed\Amazonpay\Dependency\Facade\AmazonpayToMessengerInterface;
13
use SprykerEco\Zed\Amazonpay\Dependency\Facade\AmazonpayToShipmentInterface;
14
15
class QuoteUpdateFactory implements QuoteUpdateFactoryInterface
16
{
17
18
    /**
19
     * @var \SprykerEco\Zed\Amazonpay\Business\Api\Adapter\AdapterFactory
20
     */
21
    protected $adapterFactory;
22
23
    /**
24
     * @var \SprykerEco\Shared\Amazonpay\AmazonpayConfig
25
     */
26
    protected $config;
27
28
    /**
29
     * @var \Spryker\Zed\Shipment\Business\ShipmentFacadeInterface
30
     */
31
    protected $shipmentFacade;
32
33
    /**
34
     * @var \SprykerEco\Zed\Amazonpay\Dependency\Facade\AmazonpayToMessengerInterface
35
     */
36
    protected $messengerFacade;
37
38
    /**
39
     * @param \SprykerEco\Zed\Amazonpay\Business\Api\Adapter\AdapterFactoryInterface $adapterFactory
40
     * @param \SprykerEco\Shared\Amazonpay\AmazonpayConfigInterface $config
41
     * @param \SprykerEco\Zed\Amazonpay\Dependency\Facade\AmazonpayToShipmentInterface $shipmentFacade
42
     * @param \SprykerEco\Zed\Amazonpay\Dependency\Facade\AmazonpayToMessengerInterface $messengerFacade
43
     */
44
    public function __construct(
45
        AdapterFactoryInterface $adapterFactory,
46
        AmazonpayConfigInterface $config,
47
        AmazonpayToShipmentInterface $shipmentFacade,
48
        AmazonpayToMessengerInterface $messengerFacade
49
    ) {
50
        $this->adapterFactory = $adapterFactory;
0 ignored issues
show
Documentation Bug introduced by
$adapterFactory is of type SprykerEco\Zed\Amazonpay...AdapterFactoryInterface, but the property $adapterFactory was declared to be of type SprykerEco\Zed\Amazonpay...\Adapter\AdapterFactory. 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->config = $config;
0 ignored issues
show
Documentation Bug introduced by
$config is of type SprykerEco\Shared\Amazon...mazonpayConfigInterface, but the property $config was declared to be of type SprykerEco\Shared\Amazonpay\AmazonpayConfig. 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...
52
        $this->shipmentFacade = $shipmentFacade;
0 ignored issues
show
Documentation Bug introduced by
It seems like $shipmentFacade of type SprykerEco\Zed\Amazonpay...npayToShipmentInterface is incompatible with the declared type Spryker\Zed\Shipment\Bus...ShipmentFacadeInterface of property $shipmentFacade.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
53
        $this->messengerFacade = $messengerFacade;
54
    }
55
56
    /**
57
     * @return \SprykerEco\Zed\Amazonpay\Business\Quote\QuoteUpdaterInterface
58
     */
59
    public function createShippingAddressQuoteDataUpdater()
60
    {
61
        return new ShippingAddressDataQuoteUpdater(
62
            $this->adapterFactory->createSetOrderReferenceDetailsAmazonpayAdapter(),
63
            $this->config
64
        );
65
    }
66
67
    /**
68
     * @return \SprykerEco\Zed\Amazonpay\Business\Quote\QuoteUpdaterInterface
69
     */
70
    public function createQuoteDataInitializer()
71
    {
72
        return new PrepareQuoteCollection(
73
            $this->messengerFacade,
74
            [
75
                $this->createAmazonpayDataQuoteInitializer(),
76
                $this->createCustomerDataQuoteUpdater(),
77
                $this->createShipmentDataQuoteInitializer(),
78
                $this->createPaymentDataQuoteUpdater(),
79
            ]
80
        );
81
    }
82
83
    /**
84
     * @return \SprykerEco\Zed\Amazonpay\Business\Quote\QuoteUpdaterInterface
85
     */
86
    public function createAmazonpayDataQuoteInitializer()
87
    {
88
        return new AmazonpayDataQuoteInitializer();
89
    }
90
91
    /**
92
     * @return \SprykerEco\Zed\Amazonpay\Business\Quote\QuoteUpdaterInterface
93
     */
94
    public function createShipmentDataQuoteInitializer()
95
    {
96
        return new ShipmentDataQuoteInitializer();
97
    }
98
99
    /**
100
     * @return \SprykerEco\Zed\Amazonpay\Business\Quote\QuoteUpdaterInterface
101
     */
102
    public function createShipmentDataQuoteUpdater()
103
    {
104
        return new ShipmentDataQuoteUpdater(
105
            $this->shipmentFacade
0 ignored issues
show
Bug introduced by
$this->shipmentFacade of type Spryker\Zed\Shipment\Bus...ShipmentFacadeInterface is incompatible with the type SprykerEco\Zed\Amazonpay...npayToShipmentInterface expected by parameter $shipmentFacade of SprykerEco\Zed\Amazonpay...eUpdater::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

105
            /** @scrutinizer ignore-type */ $this->shipmentFacade
Loading history...
106
        );
107
    }
108
109
    /**
110
     * @return \SprykerEco\Zed\Amazonpay\Business\Quote\QuoteUpdaterInterface
111
     */
112
    protected function createCustomerDataQuoteUpdater()
113
    {
114
        return new CustomerDataQuoteUpdater(
115
            $this->adapterFactory->createObtainProfileInformationAdapter(),
116
            $this->config
117
        );
118
    }
119
120
    /**
121
     * @return \SprykerEco\Zed\Amazonpay\Business\Quote\QuoteUpdaterInterface
122
     */
123
    protected function createPaymentDataQuoteUpdater()
124
    {
125
        return new PaymentDataQuoteUpdater();
126
    }
127
128
}
129