Completed
Push — master ( eaf845...272b76 )
by Oleksandr
13s queued 10s
created

savePaymentCrefoPayOrderItemToCrefoPayNotificationEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 1
dl 0
loc 29
rs 9.6666
c 0
b 0
f 0
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\CrefoPay\Persistence;
9
10
use Generated\Shared\Transfer\PaymentCrefoPayNotificationTransfer;
0 ignored issues
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...
11
use Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...oCrefoPayApiLogTransfer 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\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer;
0 ignored issues
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...
13
use Generated\Shared\Transfer\PaymentCrefoPayOrderItemTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...efoPayOrderItemTransfer 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 Generated\Shared\Transfer\PaymentCrefoPayTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentCrefoPayTransfer 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 Spryker\Zed\Kernel\Persistence\AbstractEntityManager;
16
use SprykerEco\Zed\CrefoPay\Persistence\Mapper\CrefoPayPersistenceMapper;
17
18
/**
19
 * @method \SprykerEco\Zed\CrefoPay\Persistence\CrefoPayPersistenceFactory getFactory()
20
 */
21
class CrefoPayEntityManager extends AbstractEntityManager implements CrefoPayEntityManagerInterface
22
{
23
    /**
24
     * @param \Generated\Shared\Transfer\PaymentCrefoPayTransfer $paymentCrefoPayTransfer
25
     *
26
     * @return \Generated\Shared\Transfer\PaymentCrefoPayTransfer
27
     */
28
    public function savePaymentCrefoPayEntity(PaymentCrefoPayTransfer $paymentCrefoPayTransfer): PaymentCrefoPayTransfer
29
    {
30
        $paymentCrefoPayEntity = $this->getFactory()
31
            ->createPaymentCrefoPayQuery()
32
            ->filterByFkSalesOrder($paymentCrefoPayTransfer->getIdSalesOrder())
33
            ->filterByCrefoPayOrderId($paymentCrefoPayTransfer->getCrefoPayOrderId())
34
            ->findOneOrCreate();
35
36
        $paymentCrefoPayEntity->fromArray(
37
            $paymentCrefoPayTransfer->modifiedToArray()
38
        );
39
        $paymentCrefoPayEntity->setFkSalesOrder($paymentCrefoPayTransfer->getIdSalesOrder());
40
41
        $paymentCrefoPayEntity->save();
42
43
        return $this->getMapper()
44
            ->mapEntityToPaymentCrefoPayTransfer(
45
                $paymentCrefoPayEntity,
46
                $paymentCrefoPayTransfer
47
            );
48
    }
49
50
    /**
51
     * @param \Generated\Shared\Transfer\PaymentCrefoPayOrderItemTransfer $paymentCrefoPayOrderItemTransfer
52
     *
53
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemTransfer
54
     */
55
    public function savePaymentCrefoPayOrderItemEntity(
56
        PaymentCrefoPayOrderItemTransfer $paymentCrefoPayOrderItemTransfer
57
    ): PaymentCrefoPayOrderItemTransfer {
58
        $paymentCrefoPayOrderItemEntity = $this->getFactory()
59
            ->createPaymentCrefoPayOrderItemQuery()
60
            ->filterByFkSalesOrderItem($paymentCrefoPayOrderItemTransfer->getIdSalesOrderItem())
61
            ->filterByFkPaymentCrefoPay($paymentCrefoPayOrderItemTransfer->getIdPaymentCrefoPay())
62
            ->findOneOrCreate();
63
64
        $paymentCrefoPayOrderItemEntity->fromArray(
65
            $paymentCrefoPayOrderItemTransfer->modifiedToArray()
66
        );
67
        $paymentCrefoPayOrderItemEntity->setFkPaymentCrefoPay($paymentCrefoPayOrderItemTransfer->getIdPaymentCrefoPay());
68
        $paymentCrefoPayOrderItemEntity->setFkSalesOrderItem($paymentCrefoPayOrderItemTransfer->getIdSalesOrderItem());
69
70
        $paymentCrefoPayOrderItemEntity->save();
71
72
        return $this->getMapper()
73
            ->mapEntityToPaymentCrefoPayOrderItemTransfer(
74
                $paymentCrefoPayOrderItemEntity,
75
                $paymentCrefoPayOrderItemTransfer
76
            );
77
    }
78
79
    /**
80
     * @param \Generated\Shared\Transfer\PaymentCrefoPayNotificationTransfer $paymentCrefoPayNotificationTransfer
81
     *
82
     * @return \Generated\Shared\Transfer\PaymentCrefoPayNotificationTransfer
83
     */
84
    public function savePaymentCrefoPayNotificationEntity(
85
        PaymentCrefoPayNotificationTransfer $paymentCrefoPayNotificationTransfer
86
    ): PaymentCrefoPayNotificationTransfer {
87
        $paymentCrefoPayNotificationEntity = $this->getFactory()
88
            ->createPaymentCrefoPayNotificationQuery()
89
            ->filterByIdPaymentCrefoPayNotification(
90
                $paymentCrefoPayNotificationTransfer->getIdPaymentCrefoPayNotification()
91
            )
92
            ->findOneOrCreate();
93
94
        $paymentCrefoPayNotificationEntity->fromArray(
95
            $paymentCrefoPayNotificationTransfer->modifiedToArray()
96
        );
97
        $paymentCrefoPayNotificationEntity->save();
98
99
        return $this->getMapper()
100
            ->mapEntityToPaymentCrefoPayNotificationTransfer(
101
                $paymentCrefoPayNotificationEntity,
102
                $paymentCrefoPayNotificationTransfer
103
            );
104
    }
105
106
    /**
107
     * @param \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer
108
     *
109
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer
110
     */
111
    public function savePaymentCrefoPayOrderItemToCrefoPayApiLogEntity(
112
        PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer
113
    ): PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer {
114
        $paymentCrefoPayOrderItemToCrefoPayApiLogEntity = $this->getFactory()
115
            ->createPaymentCrefoPayOrderItemToCrefoPayApiLogQuery()
116
            ->filterByFkPaymentCrefoPayApiLog(
117
                $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer->getIdPaymentCrefoPayApiLog()
118
            )
119
            ->filterByFkPaymentCrefoPayOrderItem(
120
                $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer->getIdPaymentCrefoPayOrderItem()
121
            )
122
            ->findOneOrCreate();
123
124
        $paymentCrefoPayOrderItemToCrefoPayApiLogEntity->fromArray(
125
            $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer->modifiedToArray()
126
        );
127
        $paymentCrefoPayOrderItemToCrefoPayApiLogEntity->setFkPaymentCrefoPayOrderItem(
128
            $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer->getIdPaymentCrefoPayOrderItem()
129
        );
130
        $paymentCrefoPayOrderItemToCrefoPayApiLogEntity->setFkPaymentCrefoPayApiLog(
131
            $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer->getIdPaymentCrefoPayApiLog()
132
        );
133
134
        $paymentCrefoPayOrderItemToCrefoPayApiLogEntity->save();
135
136
        return $this->getMapper()
137
            ->mapEntityToPaymentCrefoPayOrderItemToCrefoPayApiLogTransfer(
138
                $paymentCrefoPayOrderItemToCrefoPayApiLogEntity,
139
                $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer
140
            );
141
    }
142
143
    /**
144
     * @param \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer
145
     *
146
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer
147
     */
148
    public function savePaymentCrefoPayOrderItemToCrefoPayNotificationEntity(
149
        PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer
150
    ): PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer {
151
        $paymentCrefoPayOrderItemToCrefoPayNotificationEntity = $this->getFactory()
152
            ->createPaymentCrefoPayOrderItemToCrefoPayNotificationQuery()
153
            ->filterByFkPaymentCrefoPayNotification(
154
                $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer->getIdPaymentCrefoPayNotification()
155
            )
156
            ->filterByFkPaymentCrefoPayOrderItem(
157
                $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer->getIdPaymentCrefoPayOrderItem()
158
            )
159
            ->findOneOrCreate();
160
161
        $paymentCrefoPayOrderItemToCrefoPayNotificationEntity->fromArray(
162
            $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer->modifiedToArray()
163
        );
164
        $paymentCrefoPayOrderItemToCrefoPayNotificationEntity->setFkPaymentCrefoPayOrderItem(
165
            $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer->getIdPaymentCrefoPayOrderItem()
166
        );
167
        $paymentCrefoPayOrderItemToCrefoPayNotificationEntity->setFkPaymentCrefoPayNotification(
168
            $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer->getIdPaymentCrefoPayNotification()
169
        );
170
171
        $paymentCrefoPayOrderItemToCrefoPayNotificationEntity->save();
172
173
        return $this->getMapper()
174
            ->mapEntityToPaymentCrefoPayOrderItemToCrefoPayNotificationTransfer(
175
                $paymentCrefoPayOrderItemToCrefoPayNotificationEntity,
176
                $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer
177
            );
178
    }
179
180
    /**
181
     * @return \SprykerEco\Zed\CrefoPay\Persistence\Mapper\CrefoPayPersistenceMapper
182
     */
183
    protected function getMapper(): CrefoPayPersistenceMapper
184
    {
185
        return $this->getFactory()->createCrefoPayPersistenceMapper();
186
    }
187
}
188