AbstractMapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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\Computop\Business\Hook\Mapper\Init;
9
10
use Generated\Shared\Transfer\ComputopApiRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...putopApiRequestTransfer 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;
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...
12
use Spryker\Shared\Kernel\Transfer\TransferInterface;
13
use SprykerEco\Service\ComputopApi\ComputopApiServiceInterface;
14
use SprykerEco\Shared\Computop\Config\ComputopApiConfig;
15
use SprykerEco\Zed\Computop\ComputopConfig;
16
17
abstract class AbstractMapper implements InitMapperInterface
18
{
19
    /**
20
     * @var \SprykerEco\Zed\Computop\ComputopConfig
21
     */
22
    protected $config;
23
24
    /**
25
     * @var \SprykerEco\Service\ComputopApi\ComputopApiServiceInterface
26
     */
27
    protected $computopApiService;
28
29
    /**
30
     * @param \SprykerEco\Zed\Computop\ComputopConfig $config
31
     * @param \SprykerEco\Service\ComputopApi\ComputopApiServiceInterface $computopApiService
32
     */
33
    public function __construct(
34
        ComputopConfig $config,
35
        ComputopApiServiceInterface $computopApiService
36
    ) {
37
        $this->config = $config;
38
        $this->computopApiService = $computopApiService;
39
    }
40
41
    /**
42
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
43
     * @param \Spryker\Shared\Kernel\Transfer\TransferInterface $computopPaymentTransfer
44
     *
45
     * @return \Spryker\Shared\Kernel\Transfer\TransferInterface
46
     */
47
    public function updateComputopPaymentTransfer(QuoteTransfer $quoteTransfer, TransferInterface $computopPaymentTransfer)
48
    {
49
        $computopPaymentTransfer->setRefNr($quoteTransfer->getOrderReference());
0 ignored issues
show
Bug introduced by
The method setRefNr() does not exist on Spryker\Shared\Kernel\Transfer\TransferInterface. ( Ignorable by Annotation )

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

49
        $computopPaymentTransfer->/** @scrutinizer ignore-call */ 
50
                                  setRefNr($quoteTransfer->getOrderReference());

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...
50
51
        return $computopPaymentTransfer;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $computopPaymentTransfer returns the type Spryker\Shared\Kernel\Transfer\TransferInterface which is incompatible with the return type mandated by SprykerEco\Zed\Computop\...mputopPaymentTransfer() of Generated\Shared\Transfe...editCardPaymentTransfer.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
52
    }
53
54
    /**
55
     * @param string $merchantId
56
     * @param string $data
57
     * @param int $length
58
     *
59
     * @return string
60
     */
61
    protected function getUrlToComputop($merchantId, $data, $length)
62
    {
63
        return $this->getActionUrl() . '?' . http_build_query([
0 ignored issues
show
Bug introduced by
The method getActionUrl() does not exist on SprykerEco\Zed\Computop\...per\Init\AbstractMapper. It seems like you code against a sub-type of SprykerEco\Zed\Computop\...per\Init\AbstractMapper such as SprykerEco\Zed\Computop\...nit\InitPaydirektMapper or SprykerEco\Zed\Computop\...er\Init\InitIdealMapper or SprykerEco\Zed\Computop\...r\Init\InitSofortMapper. ( Ignorable by Annotation )

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

63
        return $this->/** @scrutinizer ignore-call */ getActionUrl() . '?' . http_build_query([
Loading history...
64
                ComputopApiConfig::MERCHANT_ID => $merchantId,
65
                ComputopApiConfig::DATA => $data,
66
                ComputopApiConfig::LENGTH => $length,
67
            ]);
68
    }
69
70
    /**
71
     * @param \Spryker\Shared\Kernel\Transfer\TransferInterface $computopPaymentTransfer
72
     *
73
     * @return \Generated\Shared\Transfer\ComputopApiRequestTransfer
74
     */
75
    protected function createRequestTransfer(TransferInterface $computopPaymentTransfer)
76
    {
77
        return (new ComputopApiRequestTransfer())
78
            ->fromArray($computopPaymentTransfer->toArray(), true);
79
    }
80
}
81