Passed
Push — feature/eco-2032-heidelpay-spl... ( c5bba6...b9cc42 )
by Oleksandr
10:41
created

PaymentReader::getIdBasketByIdSalesOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
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\Heidelpay\Business\Payment;
9
10
use Generated\Shared\Transfer\HeidelpayPaymentTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\HeidelpayPaymentTransfer 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 Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpay;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpay 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 SprykerEco\Zed\Heidelpay\Persistence\HeidelpayQueryContainerInterface;
13
14
class PaymentReader implements PaymentReaderInterface
15
{
16
    /**
17
     * @var \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayQueryContainerInterface
18
     */
19
    protected $heidelpayQueryContainer;
20
21
    /**
22
     * @param \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayQueryContainerInterface $heidelpayQueryContainer
23
     */
24
    public function __construct(HeidelpayQueryContainerInterface $heidelpayQueryContainer)
25
    {
26
        $this->heidelpayQueryContainer = $heidelpayQueryContainer;
27
    }
28
29
    /**
30
     * @param int $idSalesOrder
31
     *
32
     * @return \Generated\Shared\Transfer\HeidelpayPaymentTransfer
33
     */
34
    public function getPaymentByIdSalesOrder(int $idSalesOrder): HeidelpayPaymentTransfer
35
    {
36
        $heidelpayPaymentEntity = $this->getPaymentEntityByIdSalesOrder($idSalesOrder);
37
38
        $paymentTransfer = new HeidelpayPaymentTransfer();
39
40
        if ($heidelpayPaymentEntity === null) {
41
            return $paymentTransfer;
42
        }
43
44
        $paymentTransfer->fromArray($heidelpayPaymentEntity->toArray(), true);
45
46
        return $paymentTransfer;
47
    }
48
49
    /**
50
     * @param int $idSalesOrder
51
     *
52
     * @return string|null
53
     */
54
    public function getIdBasketByIdSalesOrder(int $idSalesOrder): ?string
55
    {
56
        $heidelpayPaymentEntity = $this->getPaymentEntityByIdSalesOrder($idSalesOrder);
57
58
        return $heidelpayPaymentEntity->getIdBasket();
59
    }
60
61
    /**
62
     * @param int $idSalesOrder
63
     *
64
     * @return \Orm\Zed\Heidelpay\Persistence\SpyPaymentHeidelpay|null
65
     */
66
    protected function getPaymentEntityByIdSalesOrder(int $idSalesOrder): ?SpyPaymentHeidelpay
67
    {
68
        $heidelpayPaymentEntity = $this->heidelpayQueryContainer
69
            ->queryPaymentByIdSalesOrder($idSalesOrder)
70
            ->findOne();
71
72
        return $heidelpayPaymentEntity;
73
    }
74
}
75