BraintreeCreatePaymentPlugin::preSave()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 2
b 0
f 0
nc 2
nop 2
dl 0
loc 7
rs 10
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Braintree\Communication\Plugin\Checkout;
9
10
use Generated\Shared\Transfer\CheckoutResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\CheckoutResponseTransfer 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\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...
12
use Spryker\Zed\Checkout\Dependency\Plugin\CheckoutPreSaveHookInterface;
13
use Spryker\Zed\Kernel\Communication\AbstractPlugin;
14
use SprykerEco\Shared\Braintree\BraintreeConfig;
15
16
/**
17
 * @method \SprykerEco\Zed\Braintree\Business\BraintreeFacadeInterface getFacade()
18
 */
19
class BraintreeCreatePaymentPlugin extends AbstractPlugin implements CheckoutPreSaveHookInterface
20
{
21
    /**
22
     * {@inheritDoc}
23
     *
24
     * @api
25
     *
26
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
27
     * @param \Generated\Shared\Transfer\CheckoutResponseTransfer $checkoutResponseTransfer
28
     *
29
     * @return \Generated\Shared\Transfer\QuoteTransfer
30
     */
31
    public function preSave(QuoteTransfer $quoteTransfer, CheckoutResponseTransfer $checkoutResponseTransfer)
32
    {
33
        if ($quoteTransfer->getPayment()->getPaymentProvider() !== BraintreeConfig::PROVIDER_NAME) {
34
            return $quoteTransfer;
35
        }
36
37
        return $this->getFacade()->createPayment($quoteTransfer, $checkoutResponseTransfer);
38
    }
39
}
40