Passed
Pull Request — master (#33)
by Aleksey
09:12 queued 01:09
created

ComputopEntityManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 20
c 1
b 0
f 0
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A updatePaymentComputopOrderItemPaymentConfirmation() 0 14 2
A savePaymentComputopNotification() 0 13 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\Persistence;
9
10
use Generated\Shared\Transfer\ComputopNotificationTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...topNotificationTransfer 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 Spryker\Zed\Kernel\Persistence\AbstractEntityManager;
12
13
/**
14
 * @method \SprykerEco\Zed\Computop\Persistence\ComputopPersistenceFactory getFactory()
15
 */
16
class ComputopEntityManager extends AbstractEntityManager implements ComputopEntityManagerInterface
17
{
18
    /**
19
     * @param \Generated\Shared\Transfer\ComputopNotificationTransfer $computopNotificationTransfer
20
     *
21
     * @return void
22
     */
23
    public function savePaymentComputopNotification(ComputopNotificationTransfer $computopNotificationTransfer): void
24
    {
25
        $paymentComputopNotificationEntity = $this->getFactory()
26
            ->createPaymentComputopNotificationQuery()
27
            ->filterByPayId($computopNotificationTransfer->getPayId())
28
            ->filterByTransId($computopNotificationTransfer->getTransId())
29
            ->filterByXId($computopNotificationTransfer->getXId())
30
            ->findOneOrCreate();
31
32
        $paymentComputopNotificationEntity->fromArray(
33
            $computopNotificationTransfer->modifiedToArray()
34
        );
35
        $paymentComputopNotificationEntity->save();
36
    }
37
38
    /**
39
     * @param \Generated\Shared\Transfer\ComputopNotificationTransfer $computopNotificationTransfer
40
     *
41
     * @return void
42
     */
43
    public function updatePaymentComputopOrderItemPaymentConfirmation(
44
        ComputopNotificationTransfer $computopNotificationTransfer
45
    ): void {
46
        $paymentComputopOrderItemEntities = $this->getFactory()
47
            ->createPaymentComputopOrderItemQuery()
48
            ->useSpyPaymentComputopQuery()
49
                ->filterByTransId($computopNotificationTransfer->getTransId())
50
                ->filterByPayId($computopNotificationTransfer->getPayId())
51
            ->endUse()
52
            ->find();
53
54
        foreach ($paymentComputopOrderItemEntities as $paymentComputopOrderItemEntity) {
55
            $paymentComputopOrderItemEntity->setIsPaymentConfirmed($computopNotificationTransfer->getIsSuccess());
56
            $paymentComputopOrderItemEntity->save();
57
        }
58
    }
59
}
60