Passed
Pull Request — feature/eco-3656/dev-paypal-ex... (#40)
by
unknown
17:08 queued 08:59
created

getComputopSalesOrderItemsCollection()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 20
rs 9.8666
c 1
b 0
f 0
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
25
     */
26
    public function getComputopPaymentByComputopTransId(string $transactionId): ComputopPaymentComputopTransfer
27
    {
28
        $computopPaymentEntity = $this->getFactory()
29
            ->createPaymentComputopQuery()
30
            ->filterByTransId($transactionId)
31
            ->findOne();
32
33
        if ($computopPaymentEntity === null) {
34
            return new ComputopPaymentComputopTransfer();
35
        }
36
37
        return $this->getFactory()
38
            ->createComputopEntityMapper()
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
            ->createSpySalesOrderItemQuery()
52
            ->filterByFkSalesOrder($computopPaymentComputopTransfer->getFKSalesOrder())
53
            ->find();
54
55
        if ($salesOrderItemsCollection->count() === 0) {
56
            return new ComputopSalesOrderItemCollectionTransfer();
57
        }
58
59
        $computopSalesOrderItemCollectionTransfer = $this->getFactory()
60
            ->createComputopEntityMapper()
61
            ->mapSalesOrderItemsCollectionToComputopSalesOrderItemCollectionTransfer(
62
                $salesOrderItemsCollection,
63
                new ComputopSalesOrderItemCollectionTransfer()
64
            );
65
66
        return $computopSalesOrderItemCollectionTransfer;
67
    }
68
69
    /**
70
     * @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
71
     *
72
     * @return \Generated\Shared\Transfer\ComputopPaymentComputopOrderItemCollectionTransfer
73
     */
74
    public function getComputopPaymentComputopOrderItemsCollection(
75
        ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
76
    ): ComputopPaymentComputopOrderItemCollectionTransfer {
77
        $computopPaymentComputopOrderItemsEntityCollection = $this->getFactory()
78
            ->createPaymentComputopOrderItemQuery()
79
            ->filterByFkPaymentComputop($computopPaymentComputopTransfer->getIdPaymentComputop())
80
            ->find();
81
82
        if ($computopPaymentComputopOrderItemsEntityCollection->count() === 0) {
83
            return new ComputopPaymentComputopOrderItemCollectionTransfer();
84
        }
85
86
        $computopPaymentComputopOrderItemsCollectionTransfer = $this->getFactory()
87
            ->createComputopEntityMapper()
88
            ->mapPaymentComputopOrderItemEntityCollectionToComputopPaymentComputopOrderItemTransferCollection(
89
                $computopPaymentComputopOrderItemsEntityCollection,
90
                new ComputopPaymentComputopOrderItemCollectionTransfer()
91
            );
92
93
        return $computopPaymentComputopOrderItemsCollectionTransfer;
94
    }
95
96
    /**
97
     * @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
98
     *
99
     * @return \Generated\Shared\Transfer\ComputopPaymentComputopDetailTransfer
100
     */
101
    public function getComputopPaymentDetail(
102
        ComputopPaymentComputopTransfer $computopPaymentComputopTransfer
103
    ): ComputopPaymentComputopDetailTransfer {
104
        $paymentComputopDetailEntity = $this->getFactory()
105
            ->createPaymentComputopDetailQuery()
106
            ->filterByIdPaymentComputop($computopPaymentComputopTransfer->getIdPaymentComputop())
107
            ->findOne();
108
109
        if ($paymentComputopDetailEntity === null) {
110
            return new ComputopPaymentComputopDetailTransfer();
111
        }
112
113
        return $this->getFactory()
114
            ->createComputopEntityMapper()
115
            ->mapPaymentComputopDetailEntityToComputopPaymentComputopDetailTransfer(
116
                $paymentComputopDetailEntity,
117
                new ComputopPaymentComputopDetailTransfer()
118
            );
119
    }
120
}
121