Completed
Push — master ( 56a686...736967 )
by Oleksandr
15s queued 11s
created

savePaymentHeidelpayDirectDebitRegistrationEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 21
rs 9.7998
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\Persistence;
9
10
use Generated\Shared\Transfer\HeidelpayDirectDebitRegistrationTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...bitRegistrationTransfer 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\HeidelpayNotificationTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...payNotificationTransfer 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 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...
13
use Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayDirectDebitRegistrationQuery;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Heidelpay\Persis...tDebitRegistrationQuery 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...
14
use Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayNotificationQuery;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Heidelpay\Persis...delpayNotificationQuery 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...
15
use Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayQuery;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Heidelpay\Persis...pyPaymentHeidelpayQuery 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...
16
use Spryker\Zed\Kernel\Persistence\AbstractEntityManager;
17
use SprykerEco\Zed\Heidelpay\Persistence\Propel\Mapper\HeidelpayPersistenceMapper;
18
19
/**
20
 * @method \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayPersistenceFactory getFactory()
21
 */
22
class HeidelpayEntityManager extends AbstractEntityManager implements HeidelpayEntityManagerInterface
23
{
24
    /**
25
     * @param \Generated\Shared\Transfer\HeidelpayPaymentTransfer $heidelpayPaymentTransfer
26
     *
27
     * @return \Generated\Shared\Transfer\HeidelpayPaymentTransfer
28
     */
29
    public function savePaymentHeidelpayEntity(HeidelpayPaymentTransfer $heidelpayPaymentTransfer): HeidelpayPaymentTransfer
30
    {
31
        $paymentHeidelpayEntity = $this->getPaymentHeidelpayQuery()
32
            ->filterByFkSalesOrder($heidelpayPaymentTransfer->getFkSalesOrder())
33
            ->findOneOrCreate();
34
35
        $paymentHeidelpayEntity->fromArray(
36
            $heidelpayPaymentTransfer->modifiedToArray()
37
        );
38
        $paymentHeidelpayEntity->save();
39
40
        return $this->getMapper()
41
            ->mapEntityToHeidelpayPaymentTransfer(
42
                $paymentHeidelpayEntity,
43
                $heidelpayPaymentTransfer
44
            );
45
    }
46
47
    /**
48
     * @param \Generated\Shared\Transfer\HeidelpayNotificationTransfer $heidelpayNotificationTransfer
49
     *
50
     * @return \Generated\Shared\Transfer\HeidelpayNotificationTransfer
51
     */
52
    public function savePaymentHeidelpayNotificationEntity(
53
        HeidelpayNotificationTransfer $heidelpayNotificationTransfer
54
    ): HeidelpayNotificationTransfer {
55
        $paymentHeidelpayNotificationEntity = $this->getPaymentHeidelpayNotificationQuery()
56
            ->filterByUniqueId($heidelpayNotificationTransfer->getUniqueId())
57
            ->findOneOrCreate();
58
59
        $paymentHeidelpayNotificationEntity->fromArray(
60
            $heidelpayNotificationTransfer->modifiedToArray()
61
        );
62
        $paymentHeidelpayNotificationEntity->save();
63
64
        return $this->getMapper()
65
            ->mapEntityToHeidelpayNotificationTransfer(
66
                $paymentHeidelpayNotificationEntity,
67
                $heidelpayNotificationTransfer
68
            );
69
    }
70
71
    /**
72
     * @param \Generated\Shared\Transfer\HeidelpayDirectDebitRegistrationTransfer $directDebitRegistrationTransfer
73
     *
74
     * @return \Generated\Shared\Transfer\HeidelpayDirectDebitRegistrationTransfer
75
     */
76
    public function savePaymentHeidelpayDirectDebitRegistrationEntity(
77
        HeidelpayDirectDebitRegistrationTransfer $directDebitRegistrationTransfer
78
    ): HeidelpayDirectDebitRegistrationTransfer {
79
        $paymentHeidelpayDirectDebitRegistrationEntity = $this->getPaymentHeidelpayDirectDebitRegistrationQuery()
80
            ->filterByRegistrationUniqueId($directDebitRegistrationTransfer->getRegistrationUniqueId())
81
            ->findOneOrCreate();
82
83
        $paymentHeidelpayDirectDebitRegistrationEntity->fromArray(
84
            $directDebitRegistrationTransfer->getAccountInfo()->modifiedToArray()
85
        );
86
        $paymentHeidelpayDirectDebitRegistrationEntity
87
            ->setFkCustomerAddress($directDebitRegistrationTransfer->getIdCustomerAddress())
88
            ->setRegistrationUniqueId($directDebitRegistrationTransfer->getRegistrationUniqueId())
89
            ->setTransactionId($directDebitRegistrationTransfer->getTransactionId());
90
91
        $paymentHeidelpayDirectDebitRegistrationEntity->save();
92
93
        return $this->getMapper()
94
            ->mapEntityToHeidelpayDirectDebitRegistrationTransfer(
95
                $paymentHeidelpayDirectDebitRegistrationEntity,
96
                $directDebitRegistrationTransfer
97
            );
98
    }
99
100
    /**
101
     * @return \SprykerEco\Zed\Heidelpay\Persistence\Propel\Mapper\HeidelpayPersistenceMapper
102
     */
103
    protected function getMapper(): HeidelpayPersistenceMapper
104
    {
105
        return $this->getFactory()->createHeidelpayPersistenceMapper();
106
    }
107
108
    /**
109
     * @return \Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayQuery
110
     */
111
    protected function getPaymentHeidelpayQuery(): SpyPaymentHeidelpayQuery
112
    {
113
        return $this->getFactory()->createPaymentHeidelpayQuery();
114
    }
115
116
    /**
117
     * @return \Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayNotificationQuery
118
     */
119
    protected function getPaymentHeidelpayNotificationQuery(): SpyPaymentHeidelpayNotificationQuery
120
    {
121
        return $this->getFactory()->createPaymentHeidelpayNotificationQuery();
122
    }
123
124
    /**
125
     * @return \Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpayDirectDebitRegistrationQuery
126
     */
127
    protected function getPaymentHeidelpayDirectDebitRegistrationQuery(): SpyPaymentHeidelpayDirectDebitRegistrationQuery
128
    {
129
        return $this->getFactory()->createPaymentHeidelpayDirectDebitRegistrationQuery();
130
    }
131
}
132