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

CheckoutPaymentChecker::isQuotePaymentValid()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
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 16
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
        $paymentTransfer = $quoteTransfer
22
            ->requirePayment()
23
            ->getPayment();
24
        if ($paymentTransfer->getPaymentProvider() !== BraintreeConfig::PROVIDER_NAME) {
25
            return true;
26
        }
27
28
        $braintreePaymentTransfer = $paymentTransfer
29
            ->requireBraintree()
30
            ->getBraintree();
31
        if (!$braintreePaymentTransfer->getNonce()) {
32
            return false;
33
        }
34
35
        return true;
36
    }
37
}
38