Completed
Pull Request — master (#64)
by
unknown
07:24
created

IsPaymentDataRequiredChecker   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 12
c 1
b 0
f 0
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isPaymentDataRequired() 0 17 2
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Payone\Business\ConditionChecker;
9
10
use Generated\Shared\Transfer\OrderTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\OrderTransfer 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\Payone\PayoneApiConstants;
12
use SprykerEco\Zed\Payone\Business\Reader\PayonePaymentReaderInterface;
13
14
class IsPaymentDataRequiredChecker implements IsPaymentDataRequiredCheckerInterface
15
{
16
    /**
17
     * @var \SprykerEco\Zed\Payone\Business\Reader\PayonePaymentReaderInterface
18
     */
19
    protected $payonePaymentReader;
20
21
    /**
22
     * @param \SprykerEco\Zed\Payone\Business\Reader\PayonePaymentReaderInterface $payonePaymentReader
23
     */
24
    public function __construct(PayonePaymentReaderInterface $payonePaymentReader)
25
    {
26
        $this->payonePaymentReader = $payonePaymentReader;
27
    }
28
29
    /**
30
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
31
     *
32
     * @return bool
33
     */
34
    public function isPaymentDataRequired(OrderTransfer $orderTransfer): bool
35
    {
36
        $paymentTransfer = $this->payonePaymentReader->getPayment($orderTransfer);
37
38
        // Return early if we don't need the iban or bic data
39
        $paymentMethod = $paymentTransfer->getPaymentMethod();
40
        $whiteList = [
41
            PayoneApiConstants::PAYMENT_METHOD_E_WALLET,
42
            PayoneApiConstants::PAYMENT_METHOD_CREDITCARD_PSEUDO,
43
            PayoneApiConstants::PAYMENT_METHOD_ONLINE_BANK_TRANSFER,
44
        ];
45
46
        if (in_array($paymentMethod, $whiteList)) {
47
            return false;
48
        }
49
50
        return true;
51
    }
52
}
53