Completed
Push — feature/paypal-express ( 45c1ed...8563e1 )
by Oleksandr
22:44 queued 22:43
created

QuoteExpander::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 8
rs 10
c 0
b 0
f 0
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\Yves\Braintree\Model\QuoteExpander;
9
10
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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 Spryker\Yves\StepEngine\Dependency\Plugin\Handler\StepHandlerPluginInterface;
12
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToCalculationClientInterface;
13
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface;
14
use Symfony\Component\HttpFoundation\Request;
15
16
class QuoteExpander implements QuoteExpanderInterface
17
{
18
    /**
19
     * @var \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface
20
     */
21
    public $quoteClient;
22
23
    /**
24
     * @var \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToCalculationClientInterface
25
     */
26
    public $calculationClient;
27
28
    /**
29
     * @var \Spryker\Yves\StepEngine\Dependency\Plugin\Handler\StepHandlerPluginInterface
30
     */
31
    public $shipmentHandlerPlugin;
32
33
    /**
34
     * @param \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface $quoteClient
35
     * @param \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToCalculationClientInterface $calculationClient
36
     * @param \Spryker\Yves\StepEngine\Dependency\Plugin\Handler\StepHandlerPluginInterface $shipmentHandlerPlugin
37
     */
38
    public function __construct(
39
        BraintreeToQuoteClientInterface $quoteClient,
40
        BraintreeToCalculationClientInterface $calculationClient,
41
        StepHandlerPluginInterface $shipmentHandlerPlugin
42
    ) {
43
        $this->quoteClient = $quoteClient;
44
        $this->calculationClient = $calculationClient;
45
        $this->shipmentHandlerPlugin = $shipmentHandlerPlugin;
46
    }
47
48
    /**
49
     * @param \Symfony\Component\HttpFoundation\Request $request
50
     * @param int $idShipmentMethod
51
     *
52
     * @return \Generated\Shared\Transfer\QuoteTransfer
53
     */
54
    public function expandQuoteWithShipmentMethod(Request $request, int $idShipmentMethod): QuoteTransfer
55
    {
56
        $quoteClient = $this->quoteClient;
57
58
        $quoteTransfer = $quoteClient->getQuote();
59
        $quoteTransfer->getShipment()->setShipmentSelection($idShipmentMethod);
60
        $quoteTransfer = $this->shipmentHandlerPlugin->addToDataClass($request, $quoteTransfer);
61
        $quoteTransfer = $this->calculationClient->recalculate($quoteTransfer);
62
63
        $quoteClient->setQuote($quoteTransfer);
64
65
        return $quoteTransfer;
66
    }
67
}
68