Completed
Pull Request — master (#4)
by Oleksandr
17:46 queued 08:55
created

savePaymentCrefoPayOrderItemToCrefoPayApiLogEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 1
dl 0
loc 22
rs 9.7998
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\CrefoPayPersistenceMapperInterface;
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->getFkSalesOrder())
33
            ->filterByCrefoPayOrderId($paymentCrefoPayTransfer->getCrefoPayOrderId())
34
            ->findOneOrCreate();
35
36
        $paymentCrefoPayEntity->fromArray(
37
            $paymentCrefoPayTransfer->modifiedToArray()
38
        );
39
            $paymentCrefoPayEntity->save();
40
41
        return $this->getMapper()
42
            ->mapEntityToPaymentCrefoPayTransfer(
43
                $paymentCrefoPayEntity,
44
                $paymentCrefoPayTransfer
45
            );
46
    }
47
48
    /**
49
     * @param \Generated\Shared\Transfer\PaymentCrefoPayOrderItemTransfer $paymentCrefoPayOrderItemTransfer
50
     *
51
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemTransfer
52
     */
53
    public function savePaymentCrefoPayOrderItemEntity(
54
        PaymentCrefoPayOrderItemTransfer $paymentCrefoPayOrderItemTransfer
55
    ): PaymentCrefoPayOrderItemTransfer {
56
        $paymentCrefoPayOrderItemEntity = $this->getFactory()
57
            ->createPaymentCrefoPayOrderItemQuery()
58
            ->filterByFkSalesOrderItem($paymentCrefoPayOrderItemTransfer->getFkSalesOrderItem())
59
            ->filterByFkPaymentCrefoPay($paymentCrefoPayOrderItemTransfer->getFkPaymentCrefoPay())
60
            ->findOneOrCreate();
61
62
        $paymentCrefoPayOrderItemEntity->fromArray(
63
            $paymentCrefoPayOrderItemTransfer->modifiedToArray()
64
        );
65
        $paymentCrefoPayOrderItemEntity->save();
66
67
        return $this->getMapper()
68
            ->mapEntityToPaymentCrefoPayOrderItemTransfer(
69
                $paymentCrefoPayOrderItemEntity,
70
                $paymentCrefoPayOrderItemTransfer
71
            );
72
    }
73
74
    /**
75
     * @param \Generated\Shared\Transfer\PaymentCrefoPayNotificationTransfer $paymentCrefoPayNotificationTransfer
76
     *
77
     * @return \Generated\Shared\Transfer\PaymentCrefoPayNotificationTransfer
78
     */
79
    public function savePaymentCrefoPayNotificationEntity(
80
        PaymentCrefoPayNotificationTransfer $paymentCrefoPayNotificationTransfer
81
    ): PaymentCrefoPayNotificationTransfer {
82
        $paymentCrefoPayNotificationEntity = $this->getFactory()
83
            ->createPaymentCrefoPayNotificationQuery()
84
            ->filterByIdPaymentCrefoPayNotification(
85
                $paymentCrefoPayNotificationTransfer->getIdPaymentCrefoPayNotification()
86
            )
87
            ->findOneOrCreate();
88
89
        $paymentCrefoPayNotificationEntity->fromArray(
90
            $paymentCrefoPayNotificationTransfer->modifiedToArray()
91
        );
92
        $paymentCrefoPayNotificationEntity->save();
93
94
        return $this->getMapper()
95
            ->mapEntityToPaymentCrefoPayNotificationTransfer(
96
                $paymentCrefoPayNotificationEntity,
97
                $paymentCrefoPayNotificationTransfer
98
            );
99
    }
100
101
    /**
102
     * @param \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer
103
     *
104
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer
105
     */
106
    public function savePaymentCrefoPayOrderItemToCrefoPayApiLogEntity(
107
        PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer
108
    ): PaymentCrefoPayOrderItemToCrefoPayApiLogTransfer {
109
        $paymentCrefoPayOrderItemToCrefoPayApiLogEntity = $this->getFactory()
110
            ->createPaymentCrefoPayOrderItemToCrefoPayApiLogQuery()
111
            ->filterByFkPaymentCrefoPayApiLog(
112
                $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer->getFkPaymentCrefoPayApiLog()
113
            )
114
            ->filterByFkPaymentCrefoPayOrderItem(
115
                $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer->getFkPaymentCrefoPayOrderItem()
116
            )
117
            ->findOneOrCreate();
118
119
        $paymentCrefoPayOrderItemToCrefoPayApiLogEntity->fromArray(
120
            $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer->modifiedToArray()
121
        );
122
        $paymentCrefoPayOrderItemToCrefoPayApiLogEntity->save();
123
124
        return $this->getMapper()
125
            ->mapEntityToPaymentCrefoPayOrderItemToCrefoPayApiLogTransfer(
126
                $paymentCrefoPayOrderItemToCrefoPayApiLogEntity,
127
                $paymentCrefoPayOrderItemToCrefoPayApiLogTransfer
128
            );
129
    }
130
131
    /**
132
     * @param \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer
133
     *
134
     * @return \Generated\Shared\Transfer\PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer
135
     */
136
    public function savePaymentCrefoPayOrderItemToCrefoPayNotificationEntity(
137
        PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer
138
    ): PaymentCrefoPayOrderItemToCrefoPayNotificationTransfer {
139
        $paymentCrefoPayOrderItemToCrefoPayNotificationEntity = $this->getFactory()
140
            ->createPaymentCrefoPayOrderItemToCrefoPayNotificationQuery()
141
            ->filterByFkPaymentCrefoPayNotification(
142
                $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer->getFkPaymentCrefoPayNotification()
143
            )
144
            ->filterByFkPaymentCrefoPayOrderItem(
145
                $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer->getFkPaymentCrefoPayOrderItem()
146
            )
147
            ->findOneOrCreate();
148
149
        $paymentCrefoPayOrderItemToCrefoPayNotificationEntity->fromArray(
150
            $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer->modifiedToArray()
151
        );
152
        $paymentCrefoPayOrderItemToCrefoPayNotificationEntity->save();
153
154
        return $this->getMapper()
155
            ->mapEntityToPaymentCrefoPayOrderItemToCrefoPayNotificationTransfer(
156
                $paymentCrefoPayOrderItemToCrefoPayNotificationEntity,
157
                $paymentCrefoPayOrderItemToCrefoPayNotificationTransfer
158
            );
159
    }
160
161
    /**
162
     * @return \SprykerEco\Zed\CrefoPay\Persistence\Mapper\CrefoPayPersistenceMapperInterface
163
     */
164
    protected function getMapper(): CrefoPayPersistenceMapperInterface
165
    {
166
        return $this->getFactory()->createCrefoPayPersistenceMapper();
167
    }
168
}
169