Completed
Push — master ( 56a686...736967 )
by Oleksandr
15s queued 11s
created

DirectDebitPaymentOptionsCalculator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
dl 0
loc 32
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getDirectDebitPaymentOptions() 0 12 3
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;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...tPaymentOptionsTransfer 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 Generated\Shared\Transfer\QuoteTransfer;
1 ignored issue
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...
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