FirstDataEntityManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A savePaymentFirstDataApiLog() 0 9 1
A savePaymentFirstData() 0 14 1
A savePaymentFirstDataNotification() 0 9 1
A savePaymentFirstDataItem() 0 14 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\FirstData\Persistence;
9
10
use Generated\Shared\Transfer\FirstDataNotificationTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ataNotificationTransfer 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\PaymentFirstDataApiLogTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...FirstDataApiLogTransfer 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\PaymentFirstDataItemTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ntFirstDataItemTransfer 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\PaymentFirstDataTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentFirstDataTransfer 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\FirstData\Persistence\SpyPaymentFirstDataApiLog;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\FirstData\Persis...yPaymentFirstDataApiLog 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\FirstData\Persistence\SpyPaymentFirstDataNotification;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\FirstData\Persis...ntFirstDataNotification 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
18
/**
19
 * @method \SprykerEco\Zed\FirstData\Persistence\FirstDataPersistenceFactory getFactory()
20
 */
21
class FirstDataEntityManager extends AbstractEntityManager implements FirstDataEntityManagerInterface
22
{
23
    /**
24
     * @param \Generated\Shared\Transfer\PaymentFirstDataTransfer $paymentFirstDataTransfer
25
     *
26
     * @return \Generated\Shared\Transfer\PaymentFirstDataTransfer
27
     */
28
    public function savePaymentFirstData(PaymentFirstDataTransfer $paymentFirstDataTransfer): PaymentFirstDataTransfer
29
    {
30
        $paymentFirstDataEntity = $this->getFactory()
31
            ->createPaymentFirstDataQuery()
32
            ->filterByFkSalesOrder($paymentFirstDataTransfer->getFkSalesOrder())
33
            ->filterByOrderReference($paymentFirstDataTransfer->getOrderReference())
34
            ->findOneOrCreate();
35
36
        $paymentFirstDataEntity->fromArray($paymentFirstDataTransfer->toArray());
37
38
        $paymentFirstDataEntity->save();
39
40
        return (new PaymentFirstDataTransfer())
41
            ->fromArray($paymentFirstDataEntity->toArray(), true);
42
    }
43
44
    /**
45
     * @param \Generated\Shared\Transfer\PaymentFirstDataItemTransfer $paymentFirstDataItemTransfer
46
     *
47
     * @return \Generated\Shared\Transfer\PaymentFirstDataItemTransfer
48
     */
49
    public function savePaymentFirstDataItem(PaymentFirstDataItemTransfer $paymentFirstDataItemTransfer): PaymentFirstDataItemTransfer
50
    {
51
        $paymentFirstDataItemEntity = $this->getFactory()
52
            ->createPaymentFirstDataItemQuery()
53
            ->filterByFkPaymentFirstData($paymentFirstDataItemTransfer->getFkPaymentFirstData())
54
            ->filterByFkSalesOrderItem($paymentFirstDataItemTransfer->getFkSalesOrderItem())
55
            ->findOneOrCreate();
56
57
        $paymentFirstDataItemEntity->fromArray($paymentFirstDataItemTransfer->toArray());
58
59
        $paymentFirstDataItemEntity->save();
60
61
        return (new PaymentFirstDataItemTransfer())
62
            ->fromArray($paymentFirstDataItemEntity->toArray(), true);
63
    }
64
65
    /**
66
     * @param \Generated\Shared\Transfer\PaymentFirstDataApiLogTransfer $paymentFirstDataApiLogTransfer
67
     *
68
     * @return \Generated\Shared\Transfer\PaymentFirstDataApiLogTransfer
69
     */
70
    public function savePaymentFirstDataApiLog(PaymentFirstDataApiLogTransfer $paymentFirstDataApiLogTransfer): PaymentFirstDataApiLogTransfer
71
    {
72
        $paymentFirstDataApiLogEntity = new SpyPaymentFirstDataApiLog();
73
        $paymentFirstDataApiLogEntity->fromArray($paymentFirstDataApiLogTransfer->toArray());
74
75
        $paymentFirstDataApiLogEntity->save();
76
77
        return (new PaymentFirstDataApiLogTransfer())
78
            ->fromArray($paymentFirstDataApiLogEntity->toArray(), true);
79
    }
80
81
    /**
82
     * @param \Generated\Shared\Transfer\FirstDataNotificationTransfer $firstDataNotificationTransfer
83
     *
84
     * @return \Generated\Shared\Transfer\FirstDataNotificationTransfer
85
     */
86
    public function savePaymentFirstDataNotification(
87
        FirstDataNotificationTransfer $firstDataNotificationTransfer
88
    ): FirstDataNotificationTransfer {
89
        $paymentFirstDataNotification = new SpyPaymentFirstDataNotification();
90
        $paymentFirstDataNotification->fromArray($firstDataNotificationTransfer->toArray());
91
        $paymentFirstDataNotification->save();
92
93
        return (new FirstDataNotificationTransfer())
94
            ->fromArray($paymentFirstDataNotification->toArray(), true);
95
    }
96
}
97