Passed
Pull Request — master (#34)
by Roman
09:40 queued 04:41
created

CheckoutPaymentChecker::isQuotePaymentValid()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
nc 3
nop 1
dl 0
loc 17
rs 9.9
c 1
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\Zed\Braintree\Business\Checkout;
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 SprykerEco\Shared\Braintree\BraintreeConfig;
12
13
class CheckoutPaymentChecker implements CheckoutPaymentCheckerInterface
14
{
15
    /**
16
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
17
     *
18
     * @return bool
19
     */
20
    public function isQuotePaymentValid(QuoteTransfer $quoteTransfer): bool
21
    {
22
        $paymentTransfer = $quoteTransfer
23
            ->requirePayment()
24
            ->getPayment();
25
        if ($paymentTransfer->getPaymentProvider() !== BraintreeConfig::PROVIDER_NAME) {
26
            return true;
27
        }
28
29
        $braintreePaymentTransfer = $paymentTransfer
30
            ->requireBraintree()
31
            ->getBraintree();
32
        if (!$braintreePaymentTransfer->getNonce()) {
33
            return false;
34
        }
35
36
        return true;
37
    }
38
}
39