Passed
Pull Request — feature/eco-3656/dev-paypal-ex... (#40)
by
unknown
09:58 queued 04:12
created

ComputopRepository   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 41
dl 0
loc 92
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getComputopPaymentComputopOrderItemsCollection() 0 20 2
A getComputopSalesOrderItemsCollection() 0 20 2
A getComputopPaymentDetail() 0 13 1
A getComputopPaymentByComputopTransId() 0 11 2
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\ComputopPaymentComputopDetailTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...tComputopDetailTransfer 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\ComputopPaymentComputopOrderItemCollectionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...rItemCollectionTransfer 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\ComputopPaymentComputopTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...PaymentComputopTransfer 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\ComputopSalesOrderItemCollectionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...rItemCollectionTransfer 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 Spryker\Zed\Kernel\Persistence\AbstractRepository;
15
16
/**
17
 * @method \SprykerEco\Zed\Computop\Persistence\ComputopPersistenceFactory getFactory();
18
 */
19
class ComputopRepository extends AbstractRepository implements ComputopRepositoryInterface
20
{
21
    /**
22
     * @param string $transactionId
23
     *
24
     * @return \Generated\Shared\Transfer\ComputopPaymentComputopTransfer
25
     */
26
    public function getComputopPaymentByComputopTransId(string $transactionId): ComputopPaymentComputopTransfer
27
    {
28
        $paymentComputopQuery = $this->getFactory()->createPaymentComputopQuery();
29
        $computopPaymentEntity = $paymentComputopQuery->filterByTransId($transactionId)->findOne();
30
        if ($computopPaymentEntity === null) {
31
            return new ComputopPaymentComputopTransfer();
32
        }
33
34
        return $this->getFactory()
35
            ->createComputopEntityMapper()
36
            ->mapComputopPaymentEntityToComputopPaymentTransfer($computopPaymentEntity, new ComputopPaymentComputopTransfer());
37
    }
38
39
    /**
40
     * @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
41
     *
42
     * @return \Generated\Shared\Transfer\ComputopSalesOrderItemCollectionTransfer
43
     */
44
    public function getComputopSalesOrderItemsCollection(
45
        ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
46
    ): ComputopSalesOrderItemCollectionTransfer {
47
        $salesOrderItemsCollection = $this
48
            ->getFactory()->createSpySalesOrderItemQuery()
49
            ->filterByFkSalesOrder($computopPaymentComputopTransfer->getFKSalesOrder())
50
            ->find();
51
52
        if (empty($salesOrderItemsCollection)) {
53
            return new ComputopSalesOrderItemCollectionTransfer();
54
        }
55
56
        $computopSalesOrderItemCollectionTransfer = $this->getFactory()
57
            ->createComputopEntityMapper()
58
            ->mapSalesOrderItemsCollectionToComputopSalesOrderItemCollectionTransfer(
59
                $salesOrderItemsCollection,
60
                new ComputopSalesOrderItemCollectionTransfer()
61
            );
62
63
        return $computopSalesOrderItemCollectionTransfer;
64
    }
65
66
    /**
67
     * @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
68
     *
69
     * @return \Generated\Shared\Transfer\ComputopPaymentComputopOrderItemCollectionTransfer
70
     */
71
    public function getComputopPaymentComputopOrderItemsCollection(
72
        ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
73
    ): ComputopPaymentComputopOrderItemCollectionTransfer {
74
        $computopPaymentComputopOrderItemsEntityCollection = $this->getFactory()
75
            ->createPaymentComputopOrderItemQuery()
76
            ->filterByFkPaymentComputop($computopPaymentComputopTransfer->getIdPaymentComputop())
77
            ->find();
78
79
        if (empty($computopPaymentComputopOrderItemsEntityCollection)) {
80
            return new ComputopPaymentComputopOrderItemCollectionTransfer();
81
        }
82
83
        $computopPaymentComputopOrderItemsCollectionTransfer = $this->getFactory()
84
            ->createComputopEntityMapper()
85
            ->mapPaymentComputopOrderItemEntityCollectionToComputopPaymentComputopOrderItemTransferCollection(
86
                $computopPaymentComputopOrderItemsEntityCollection,
87
                new ComputopPaymentComputopOrderItemCollectionTransfer()
88
            );
89
90
        return $computopPaymentComputopOrderItemsCollectionTransfer;
91
    }
92
93
    /**
94
     * @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
95
     *
96
     * @return \Generated\Shared\Transfer\ComputopPaymentComputopDetailTransfer
97
     */
98
    public function getComputopPaymentDetail(
99
        ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
100
    ): ComputopPaymentComputopDetailTransfer {
101
        $paymentComputopDetailEntity = $this->getFactory()
102
            ->createPaymentComputopDetailQuery()
103
            ->filterByIdPaymentComputop($computopPaymentComputopTransfer->getIdPaymentComputop())
104
            ->findOne();
105
106
        return $this->getFactory()
107
            ->createComputopEntityMapper()
108
            ->mapPaymentComputopDetailEntityToComputopPaymentComputopDetailTransfer(
109
                $paymentComputopDetailEntity,
110
                new ComputopPaymentComputopDetailTransfer()
111
            );
112
    }
113
}
114