Passed
Push — feature/eco-3047/eco-3049-invo... ( 13c8f0...216985 )
by Aleksey
04:06
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
c 1
b 0
f 0
rs 10
cc 1
nc 1
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\HeidelpayNotificationTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...payNotificationTransfer 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 IsPaidNotificationReceivedOmsCondition 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
        $heidelpayPaymentTransfer = $this->repository
38
            ->findHeidelpayPaymentByIdSalesOrder($orderItem->getFkSalesOrder());
39
40
        if ($heidelpayPaymentTransfer === null) {
41
            return false;
42
        }
43
44
        $heidelpayNotificationTransfer = $this->repository
45
            ->findPaymentHeidelpayNotificationByUniqueId($heidelpayPaymentTransfer->getIdPaymentReference());
46
47
        if ($heidelpayNotificationTransfer === null) {
48
            return false;
49
        }
50
51
        return $this->isNotificationSuccessful($heidelpayNotificationTransfer);
52
    }
53
54
    /**
55
     * @param \Generated\Shared\Transfer\HeidelpayNotificationTransfer $heidelpayNotificationTransfer
56
     *
57
     * @return bool
58
     */
59
    protected function isNotificationSuccessful(HeidelpayNotificationTransfer $heidelpayNotificationTransfer): bool
60
    {
61
        return $heidelpayNotificationTransfer->getResult() === HeidelpayConfig::NOTIFICATION_STATUS_OK;
62
    }
63
}
64