Passed
Push — bugfix/supesc-213-is-capture-a... ( b2b98a )
by Roman
08:15
created

CaptureTransactionChecker   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
dl 0
loc 25
c 1
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isSuccessful() 0 7 1
A __construct() 0 3 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\Business\Checker;
9
10
use Orm\Zed\Sales\Persistence\SpySalesOrderItem;
11
use SprykerEco\Zed\Heidelpay\Persistence\HeidelpayQueryContainerInterface;
12
13
class CaptureTransactionChecker implements CaptureTransactionCheckerInterface
14
{
15
    /**
16
     * @var \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayQueryContainerInterface
17
     */
18
    protected $heidelpayQueryContainer;
19
20
    /**
21
     * @param \SprykerEco\Zed\Heidelpay\Persistence\HeidelpayQueryContainerInterface $heidelpayQueryContainer
22
     */
23
    public function __construct(HeidelpayQueryContainerInterface $heidelpayQueryContainer)
24
    {
25
        $this->heidelpayQueryContainer = $heidelpayQueryContainer;
26
    }
27
28
    /**
29
     * {@inheritDoc}
30
     */
31
    public function isSuccessful(SpySalesOrderItem $orderItem): bool
32
    {
33
        $successTransactionLogEntity = $this->heidelpayQueryContainer
34
            ->queryCaptureSuccessTransactionLog($orderItem->getFkSalesOrder())
35
            ->findOne();
36
37
        return ($successTransactionLogEntity !== null);
38
    }
39
}
40