QuotePaymentInitMapper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A map() 0 21 3
A __construct() 0 8 1
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\Ratepay\Business\Api\Mapper;
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 Generated\Shared\Transfer\RatepayPaymentInitTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...epayPaymentInitTransfer 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
use SprykerEco\Zed\Ratepay\Business\Service\PaymentMethodExtractorInterface;
13
14
class QuotePaymentInitMapper extends BaseMapper
15
{
16
    /**
17
     * @var \Generated\Shared\Transfer\QuoteTransfer
18
     */
19
    protected $quoteTransfer;
20
21
    /**
22
     * @var \Generated\Shared\Transfer\RatepayPaymentInitTransfer
23
     */
24
    protected $ratepayPaymentInitTransfer;
25
26
    /**
27
     * @var \SprykerEco\Zed\Ratepay\Business\Service\PaymentMethodExtractorInterface
28
     */
29
    protected $paymentMethodExtractor;
30
31
    /**
32
     * @param \Generated\Shared\Transfer\RatepayPaymentInitTransfer $ratepayPaymentInitTransfer
33
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
34
     * @param \SprykerEco\Zed\Ratepay\Business\Service\PaymentMethodExtractorInterface $paymentMethodExtractor
35
     */
36
    public function __construct(
37
        RatepayPaymentInitTransfer $ratepayPaymentInitTransfer,
38
        QuoteTransfer $quoteTransfer,
39
        PaymentMethodExtractorInterface $paymentMethodExtractor
40
    ) {
41
        $this->ratepayPaymentInitTransfer = $ratepayPaymentInitTransfer;
42
        $this->quoteTransfer = $quoteTransfer;
43
        $this->paymentMethodExtractor = $paymentMethodExtractor;
44
    }
45
46
    /**
47
     * @return void
48
     */
49
    public function map()
50
    {
51
        if ($this->quoteTransfer->getPayment()) {
52
            $paymentMethodName = $this->quoteTransfer
53
                ->getPayment()
54
                ->getPaymentMethod();
55
56
            $this->ratepayPaymentInitTransfer
57
                ->setPaymentMethodName($paymentMethodName);
58
        }
59
60
        $paymentMethod = $this->paymentMethodExtractor->extractPaymentMethod($this->quoteTransfer);
61
        if ($paymentMethod) {
62
            $this->ratepayPaymentInitTransfer
63
                ->setTransactionId($paymentMethod->getTransactionId())
0 ignored issues
show
Bug introduced by
The method getTransactionId() does not exist on Spryker\Shared\Kernel\Transfer\AbstractTransfer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
                ->setTransactionId($paymentMethod->/** @scrutinizer ignore-call */ getTransactionId())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64
                ->setTransactionShortId($paymentMethod->getTransactionShortId())
0 ignored issues
show
Bug introduced by
The method getTransactionShortId() does not exist on Spryker\Shared\Kernel\Transfer\AbstractTransfer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

64
                ->setTransactionShortId($paymentMethod->/** @scrutinizer ignore-call */ getTransactionShortId())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
65
                ->setDeviceFingerprint($paymentMethod->getDeviceFingerprint());
0 ignored issues
show
Bug introduced by
The method getDeviceFingerprint() does not exist on Spryker\Shared\Kernel\Transfer\AbstractTransfer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
                ->setDeviceFingerprint($paymentMethod->/** @scrutinizer ignore-call */ getDeviceFingerprint());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
66
        }
67
68
        $this->ratepayPaymentInitTransfer
69
            ->setCustomerId($this->quoteTransfer->getCustomer()->getIdCustomer());
70
    }
71
}
72