Passed
Push — feature/eco-3623-payone-pay-u-... ( 0a3f73...4fb100 )
by Roman
03:15
created

getComputopPaymentComputopOrderItemsCollection()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 17
rs 9.9
cc 2
nc 2
nop 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\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|null
25
     */
26
    public function findComputopPaymentByComputopTransId(string $transactionId): ?ComputopPaymentComputopTransfer
27
    {
28
        $computopPaymentEntity = $this->getFactory()
29
            ->getPaymentComputopQuery()
30
            ->filterByTransId($transactionId)
31
            ->findOne();
32
33
        if ($computopPaymentEntity === null) {
34
            return null;
35
        }
36
37
        return $this->getFactory()
38
            ->createComputopMapper()
39
            ->mapComputopPaymentEntityToComputopPaymentTransfer($computopPaymentEntity, new ComputopPaymentComputopTransfer());
40
    }
41
42
    /**
43
     * @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
44
     *
45
     * @return \Generated\Shared\Transfer\ComputopSalesOrderItemCollectionTransfer
46
     */
47
    public function getComputopSalesOrderItemsCollection(
48
        ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
49
    ): ComputopSalesOrderItemCollectionTransfer {
50
        $salesOrderItemsCollection = $this->getFactory()
51
            ->getSpySalesOrderItemQuery()
52
            ->filterByFkSalesOrder($computopPaymentComputopTransfer->getFKSalesOrder())
53
            ->find();
54
55
        if ($salesOrderItemsCollection->count() === 0) {
56
            return new ComputopSalesOrderItemCollectionTransfer();
57
        }
58
59
        return $this->getFactory()
60
            ->createComputopMapper()
61
            ->mapSalesOrderItemsCollectionToComputopSalesOrderItemCollectionTransfer(
62
                $salesOrderItemsCollection,
63
                new ComputopSalesOrderItemCollectionTransfer()
64
            );
65
    }
66
67
    /**
68
     * @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
69
     *
70
     * @return \Generated\Shared\Transfer\ComputopPaymentComputopOrderItemCollectionTransfer
71
     */
72
    public function getComputopPaymentComputopOrderItemsCollection(
73
        ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
74
    ): ComputopPaymentComputopOrderItemCollectionTransfer {
75
        $computopPaymentComputopOrderItemsEntityCollection = $this->getFactory()
76
            ->getPaymentComputopOrderItemQuery()
77
            ->filterByFkPaymentComputop($computopPaymentComputopTransfer->getIdPaymentComputop())
78
            ->find();
79
80
        if ($computopPaymentComputopOrderItemsEntityCollection->count() === 0) {
81
            return new ComputopPaymentComputopOrderItemCollectionTransfer();
82
        }
83
84
        return $this->getFactory()
85
            ->createComputopMapper()
86
            ->mapPaymentComputopOrderItemEntityCollectionToComputopPaymentComputopOrderItemTransferCollection(
87
                $computopPaymentComputopOrderItemsEntityCollection,
88
                new ComputopPaymentComputopOrderItemCollectionTransfer()
89
            );
90
    }
91
92
    /**
93
     * @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
94
     *
95
     * @return \Generated\Shared\Transfer\ComputopPaymentComputopDetailTransfer|null
96
     */
97
    public function findComputopPaymentDetail(
98
        ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
99
    ): ?ComputopPaymentComputopDetailTransfer {
100
        $paymentComputopDetailEntity = $this->getFactory()
101
            ->getPaymentComputopDetailQuery()
102
            ->filterByIdPaymentComputop($computopPaymentComputopTransfer->getIdPaymentComputop())
103
            ->findOne();
104
105
        if ($paymentComputopDetailEntity === null) {
106
            return null;
107
        }
108
109
        return $this->getFactory()
110
            ->createComputopMapper()
111
            ->mapPaymentComputopDetailEntityToComputopPaymentComputopDetailTransfer(
112
                $paymentComputopDetailEntity,
113
                new ComputopPaymentComputopDetailTransfer()
114
            );
115
    }
116
}
117