DirectDebitPaymentOptionsCalculator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
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\DirectDebit;
9
10
use Generated\Shared\Transfer\HeidelpayDirectDebitPaymentOptionsTransfer;
11
use Generated\Shared\Transfer\QuoteTransfer;
12
13
class DirectDebitPaymentOptionsCalculator implements DirectDebitPaymentOptionsCalculatorInterface
14
{
15
    /**
16
     * @var \SprykerEco\Zed\Heidelpay\Business\Payment\DirectDebit\PaymentOption\DirectDebitPaymentOptionInterface[]
17
     */
18
    protected $paymentOptions;
19
20
    /**
21
     * @param \SprykerEco\Zed\Heidelpay\Business\Payment\DirectDebit\PaymentOption\DirectDebitPaymentOptionInterface[] $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\HeidelpayDirectDebitPaymentOptionsTransfer
32
     */
33
    public function getDirectDebitPaymentOptions(QuoteTransfer $quoteTransfer): HeidelpayDirectDebitPaymentOptionsTransfer
34
    {
35
        $paymentOptionsTransfer = new HeidelpayDirectDebitPaymentOptionsTransfer();
36
37
        foreach ($this->paymentOptions as $paymentOption) {
38
            if (!$paymentOption->isOptionAvailableForQuote($quoteTransfer)) {
39
                continue;
40
            }
41
            $paymentOptionsTransfer = $paymentOption->addPaymentOption($quoteTransfer, $paymentOptionsTransfer);
42
        }
43
44
        return $paymentOptionsTransfer;
45
    }
46
}
47