DirectDebitResponseSaver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 14 2
A savePaymentComputopDetailEntity() 0 5 1
A savePaymentComputopEntity() 0 6 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\Computop\Business\Payment\Handler\Saver\Init;
9
10
use Generated\Shared\Transfer\ComputopDirectDebitInitResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...bitInitResponseTransfer 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
13
class DirectDebitResponseSaver extends AbstractResponseSaver
14
{
15
    /**
16
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
17
     *
18
     * @return \Generated\Shared\Transfer\QuoteTransfer
19
     */
20
    public function save(QuoteTransfer $quoteTransfer)
21
    {
22
        $responseTransfer = $quoteTransfer->getPayment()->getComputopDirectDebit()->getDirectDebitInitResponse();
23
        $this->setPaymentEntity($responseTransfer->getHeader()->getTransId());
24
        if ($responseTransfer->getHeader()->getIsSuccess()) {
25
            $this->getTransactionHandler()->handleTransaction(
26
                function () use ($responseTransfer) {
27
                    $this->savePaymentComputopEntity($responseTransfer);
28
                    $this->savePaymentComputopDetailEntity($responseTransfer);
29
                }
30
            );
31
        }
32
33
        return $quoteTransfer;
34
    }
35
36
    /**
37
     * @param \Generated\Shared\Transfer\ComputopDirectDebitInitResponseTransfer $responseTransfer
38
     *
39
     * @return void
40
     */
41
    protected function savePaymentComputopEntity(ComputopDirectDebitInitResponseTransfer $responseTransfer)
42
    {
43
        $paymentEntity = $this->getPaymentEntity();
44
        $paymentEntity->setPayId($responseTransfer->getHeader()->getPayId());
45
        $paymentEntity->setXId($responseTransfer->getHeader()->getXId());
46
        $paymentEntity->save();
47
    }
48
49
    /**
50
     * @param \Generated\Shared\Transfer\ComputopDirectDebitInitResponseTransfer $responseTransfer
51
     *
52
     * @return void
53
     */
54
    protected function savePaymentComputopDetailEntity(ComputopDirectDebitInitResponseTransfer $responseTransfer)
55
    {
56
        $paymentEntityDetails = $this->getPaymentEntity()->getSpyPaymentComputopDetail();
57
        $paymentEntityDetails->fromArray($responseTransfer->toArray());
58
        $paymentEntityDetails->save();
59
    }
60
}
61