getCreditCardPaymentOptions()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 12
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\Zed\Heidelpay\Business\Payment\CreditCard;
9
10
use Generated\Shared\Transfer\HeidelpayCreditCardPaymentOptionsTransfer;
11
use Generated\Shared\Transfer\QuoteTransfer;
12
13
class PaymentOptionsCalculator implements PaymentOptionsCalculatorInterface
14
{
15
    /**
16
     * @var \SprykerEco\Zed\Heidelpay\Business\Payment\CreditCard\PaymentOption\PaymentOptionInterface[]
17
     */
18
    protected $paymentOptions;
19
20
    /**
21
     * @param \SprykerEco\Zed\Heidelpay\Business\Payment\CreditCard\PaymentOption\PaymentOptionInterface[] $paymentOptions
22
     */
23
    public function __construct(array $paymentOptions)
24
    {
25
        $this->paymentOptions = $paymentOptions;
26
    }
27
28
    /**
29
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
30
     *
31
     * @return \Generated\Shared\Transfer\HeidelpayCreditCardPaymentOptionsTransfer
32
     */
33
    public function getCreditCardPaymentOptions(QuoteTransfer $quoteTransfer): HeidelpayCreditCardPaymentOptionsTransfer
34
    {
35
        $paymentOptionsTransfer = new HeidelpayCreditCardPaymentOptionsTransfer();
36
37
        foreach ($this->paymentOptions as $paymentOption) {
38
            if (!$paymentOption->isOptionAvailableForQuote($quoteTransfer)) {
39
                continue;
40
            }
41
            $paymentOption->hydrateToPaymentOptions($quoteTransfer, $paymentOptionsTransfer);
42
        }
43
44
        return $paymentOptionsTransfer;
45
    }
46
}
47