PaymentSaver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPaymentMethodByOrderId() 0 5 1
A updatePaymentMethodByPaymentResponse() 0 9 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\Ratepay\Business\Payment;
9
10
use Generated\Shared\Transfer\RatepayResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\RatepayResponseTransfer 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 SprykerEco\Zed\Ratepay\Persistence\RatepayQueryContainerInterface;
12
13
class PaymentSaver implements PaymentSaverInterface
14
{
15
    /**
16
     * @var \SprykerEco\Zed\Ratepay\Persistence\RatepayQueryContainerInterface
17
     */
18
    protected $queryContainer;
19
20
    /**
21
     * @param \SprykerEco\Zed\Ratepay\Persistence\RatepayQueryContainerInterface $queryContainer
22
     */
23
    public function __construct(
24
        RatepayQueryContainerInterface $queryContainer
25
    ) {
26
        $this->queryContainer = $queryContainer;
27
    }
28
29
    /**
30
     * @param \Generated\Shared\Transfer\RatepayResponseTransfer $ratepayPaymentResponseTransfer
31
     * @param int $orderId
32
     *
33
     * @return void
34
     */
35
    public function updatePaymentMethodByPaymentResponse(RatepayResponseTransfer $ratepayPaymentResponseTransfer, $orderId)
36
    {
37
        $paymentMethod = $this->getPaymentMethodByOrderId($orderId);
38
        if ($paymentMethod) {
0 ignored issues
show
introduced by
$paymentMethod is of type Orm\Zed\Ratepay\Persistence\SpyPaymentRatepay, thus it always evaluated to true.
Loading history...
39
            $paymentMethod->setTransactionId($ratepayPaymentResponseTransfer->getTransactionId());
40
            $paymentMethod->setTransactionShortId($ratepayPaymentResponseTransfer->getTransactionShortId());
41
            $paymentMethod->setResultCode($ratepayPaymentResponseTransfer->getResultCode());
42
            $paymentMethod->setDescriptor($ratepayPaymentResponseTransfer->getDescriptor());
43
            $paymentMethod->save();
44
        }
45
    }
46
47
    /**
48
     * @param int $orderId
49
     *
50
     * @return \Orm\Zed\Ratepay\Persistence\SpyPaymentRatepay
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Ratepay\Persistence\SpyPaymentRatepay 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...
51
     */
52
    protected function getPaymentMethodByOrderId($orderId)
53
    {
54
        return $this->queryContainer
55
            ->queryPayments()
56
            ->findByFkSalesOrder($orderId)->getFirst();
57
    }
58
}
59