Completed
Push — master ( 2a18cf...56a686 )
by Oleksandr
14s queued 11s
created

PaymentWriter::getIdPaymentReferenceFromResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
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;
9
10
use Generated\Shared\Transfer\HeidelpayPaymentTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\HeidelpayPaymentTransfer 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\HeidelpayResponseTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...idelpayResponseTransfer 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\Heidelpay\Persistence\HeidelpayEntityManagerInterface;
13
14
class PaymentWriter implements PaymentWriterInterface
15
{
16
    /**
17
     * @var \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayEntityManagerInterface
18
     */
19
    protected $entityManager;
20
21
    /**
22
     * @param \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayEntityManagerInterface $entityManager
23
     */
24
    public function __construct(HeidelpayEntityManagerInterface $entityManager)
25
    {
26
        $this->entityManager = $entityManager;
27
    }
28
29
    /**
30
     * @param \Generated\Shared\Transfer\HeidelpayResponseTransfer $responseTransfer
31
     *
32
     * @return void
33
     */
34
    public function updateHeidelpayPaymentWithResponse(HeidelpayResponseTransfer $responseTransfer): void
35
    {
36
        $heidelpayPaymentTransfer = $this->createHeidelpayPaymentTransfer($responseTransfer);
37
        $this->entityManager->savePaymentHeidelpayEntity($heidelpayPaymentTransfer);
38
    }
39
40
    /**
41
     * @param \Generated\Shared\Transfer\HeidelpayResponseTransfer $responseTransfer
42
     *
43
     * @return \Generated\Shared\Transfer\HeidelpayPaymentTransfer
44
     */
45
    protected function createHeidelpayPaymentTransfer(HeidelpayResponseTransfer $responseTransfer): HeidelpayPaymentTransfer
46
    {
47
        return (new HeidelpayPaymentTransfer())
48
            ->setFkSalesOrder($responseTransfer->getIdSalesOrder())
49
            ->setIdPaymentReference($this->getIdPaymentReferenceFromResponse($responseTransfer))
50
            ->setConnectorInvoiceAccountInfo($responseTransfer->getConnectorInvoiceAccountInfo());
51
    }
52
53
    /**
54
     * @param \Generated\Shared\Transfer\HeidelpayResponseTransfer $responseTransfer
55
     *
56
     * @return string|null
57
     */
58
    protected function getIdPaymentReferenceFromResponse(HeidelpayResponseTransfer $responseTransfer): ?string
59
    {
60
        return $responseTransfer->getIdPaymentReference() ?? $responseTransfer->getIdTransactionUnique();
61
    }
62
}
63