Passed
Pull Request — feature/eco-574/eco-2266-check... (#12)
by Ruslan
09:24 queued 03:24
created

AfterPayAvailablePaymentMethodsPluginHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addAvailablePaymentMethodsToQuote() 0 10 2
A __construct() 0 3 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\Yves\AfterPay\Handler;
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\Client\AfterPay\AfterPayClientInterface;
12
13
class AfterPayAvailablePaymentMethodsPluginHandler implements AfterPayAvailablePaymentMethodsPluginHandlerInterface
14
{
15
    /**
16
     * @var \SprykerEco\Client\AfterPay\AfterPayClientInterface
17
     */
18
    protected $afterPayClient;
19
20
    /**
21
     * @param \SprykerEco\Client\AfterPay\AfterPayClientInterface $afterPayClient
22
     */
23
    public function __construct(AfterPayClientInterface $afterPayClient)
24
    {
25
        $this->afterPayClient = $afterPayClient;
26
    }
27
28
    /**
29
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
30
     *
31
     * @return \Generated\Shared\Transfer\QuoteTransfer
32
     */
33
    public function addAvailablePaymentMethodsToQuote(QuoteTransfer $quoteTransfer): QuoteTransfer
34
    {
35
        if ($quoteTransfer->getAfterPayAvailablePaymentMethods() !== null) {
36
            return $quoteTransfer;
37
        }
38
39
        $availablePaymentMethods = $this->afterPayClient->getAvailablePaymentMethods($quoteTransfer);
40
41
        return $quoteTransfer
42
            ->setAfterPayAvailablePaymentMethods($availablePaymentMethods);
43
    }
44
}
45