Passed
Push — feature/eco-3623-payone-pay-u-... ( f8a65c...d3b573 )
by Roman
04:40
created

getOrderItemPaymentStatusFromComputopApiResponseHeaderTransfer()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 19
rs 9.6111
c 0
b 0
f 0
cc 5
nc 4
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\Business\Payment\Handler\Saver\Init;
9
10
use Generated\Shared\Transfer\ComputopApiResponseHeaderTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...iResponseHeaderTransfer 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 Spryker\Zed\Kernel\Persistence\EntityManager\TransactionTrait;
12
use SprykerEco\Shared\Computop\ComputopConfig as SharedComputopConfig;
13
use SprykerEco\Zed\Computop\ComputopConfig;
14
use SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface;
15
use SprykerEco\Zed\Computop\Persistence\ComputopQueryContainerInterface;
16
17
abstract class AbstractResponseSaver implements InitResponseSaverInterface
18
{
19
    use TransactionTrait;
20
21
    /**
22
     * @var \SprykerEco\Zed\Computop\Persistence\ComputopQueryContainerInterface $queryContainer
23
     */
24
    protected $queryContainer;
25
26
    /**
27
     * @var \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface
28
     */
29
    protected $omsFacade;
30
31
    /**
32
     * @var \Orm\Zed\Computop\Persistence\SpyPaymentComputop
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Computop\Persistence\SpyPaymentComputop 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...
33
     */
34
    protected $paymentEntity;
35
36
    /**
37
     * @var \SprykerEco\Zed\Computop\ComputopConfig
38
     */
39
    protected $config;
40
41
    /**
42
     * @param \SprykerEco\Zed\Computop\Persistence\ComputopQueryContainerInterface $queryContainer
43
     * @param \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface $omsFacade
44
     * @param \SprykerEco\Zed\Computop\ComputopConfig $config
45
     */
46
    public function __construct(
47
        ComputopQueryContainerInterface $queryContainer,
48
        ComputopToOmsFacadeInterface $omsFacade,
49
        ComputopConfig $config
50
    ) {
51
        $this->queryContainer = $queryContainer;
52
        $this->omsFacade = $omsFacade;
53
        $this->config = $config;
54
    }
55
56
    /**
57
     * @param string $transactionId
58
     *
59
     * @return void
60
     */
61
    protected function setPaymentEntity($transactionId)
62
    {
63
        $this->paymentEntity = $this->queryContainer->queryPaymentByTransactionId($transactionId)->findOne();
64
    }
65
66
    /**
67
     * @return \Orm\Zed\Computop\Persistence\SpyPaymentComputop
68
     */
69
    protected function getPaymentEntity()
70
    {
71
        return $this->paymentEntity;
72
    }
73
74
    /**
75
     * @param \Generated\Shared\Transfer\ComputopApiResponseHeaderTransfer $computopApiResponseHeaderTransfer
76
     *
77
     * @return string
78
     */
79
    protected function getOrderItemPaymentStatusFromComputopApiResponseHeaderTransfer(
80
        ComputopApiResponseHeaderTransfer $computopApiResponseHeaderTransfer
81
    ): string {
82
        if ($computopApiResponseHeaderTransfer->getStatus() === null) {
83
            return $this->config->getOmsStatusNew();
84
        }
85
86
        if ($computopApiResponseHeaderTransfer->getStatus() === SharedComputopConfig::AUTHORIZE_REQUEST_STATUS) {
87
            return $this->config->getAuthorizeRequestOmsStatus();
88
        }
89
90
        if (
91
            $computopApiResponseHeaderTransfer->getStatus() === SharedComputopConfig::SUCCESS_OK &&
92
            $computopApiResponseHeaderTransfer->getDescription() === SharedComputopConfig::SUCCESS_STATUS
93
        ) {
94
            return $this->config->getOmsStatusAuthorized();
95
        }
96
97
        return $this->config->getOmsStatusNew();
98
    }
99
}
100