Passed
Push — feature/eco-3135/eco-3149-dire... ( b1393a...0436c5 )
by Aleksey
05:03
created

check()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 13
c 1
b 0
f 0
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\Heidelpay\Communication\Oms\Condition;
9
10
use Generated\Shared\Transfer\HeidelpayTransactionLogTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...yTransactionLogTransfer 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\Sales\Persistence\SpySalesOrderItem;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\Sales\Persistence\SpySalesOrderItem 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\Shared\Heidelpay\HeidelpayConfig;
13
use SprykerEco\Zed\Heidelpay\Persistence\HeidelpayRepositoryInterface;
14
15
class IsDebitOnRegistrationCompletedOmsCondition implements HeidelpayOmsConditionInterface
16
{
17
    /**
18
     * @var \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayRepositoryInterface
19
     */
20
    protected $repository;
21
22
    /**
23
     * @param \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayRepositoryInterface $repository
24
     */
25
    public function __construct(HeidelpayRepositoryInterface $repository)
26
    {
27
        $this->repository = $repository;
28
    }
29
30
    /**
31
     * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem
32
     *
33
     * @return bool
34
     */
35
    public function check(SpySalesOrderItem $orderItem): bool
36
    {
37
        $externalTransactionLog = $this->repository
38
            ->findHeidelpayTransactionLogByIdSalesOrderAndTransactionType(
39
                $orderItem->getFkSalesOrder(),
40
                HeidelpayConfig::TRANSACTION_TYPE_EXTERNAL_RESPONSE
41
            );
42
43
        if ($externalTransactionLog === null) {
44
            return false;
45
        }
46
47
        return $this->isTransactionSuccessful($externalTransactionLog);
48
    }
49
50
    /**
51
     * @param \Generated\Shared\Transfer\HeidelpayTransactionLogTransfer $externalTransactionLog
52
     *
53
     * @return bool
54
     */
55
    protected function isTransactionSuccessful(HeidelpayTransactionLogTransfer $externalTransactionLog): bool
56
    {
57
        return $externalTransactionLog->getResponseCode() === HeidelpayConfig::EXTERNAL_RESPONSE_TRANSACTION_STATUS_OK;
58
    }
59
}
60