Passed
Pull Request — master (#4)
by Aleksey
07:29 queued 04:02
created

IsCancelCallSuccessfulOmsCondition   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A check() 0 9 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\CrefoPay\Business\Oms\Condition;
9
10
use SprykerEco\Zed\CrefoPay\Business\Reader\CrefoPayReaderInterface;
11
12
class IsCancelCallSuccessfulOmsCondition implements CrefoPayOmsConditionInterface
13
{
14
    protected const REQUEST_TYPE = 'cancel';
15
16
    /**
17
     * @var \SprykerEco\Zed\CrefoPay\Business\Reader\CrefoPayReaderInterface
18
     */
19
    protected $reader;
20
21
    /**
22
     * @param \SprykerEco\Zed\CrefoPay\Business\Reader\CrefoPayReaderInterface $reader
23
     */
24
    public function __construct(CrefoPayReaderInterface $reader)
25
    {
26
        $this->reader = $reader;
27
    }
28
29
    /**
30
     * @param int $idSalesOrderItem
31
     *
32
     * @return bool
33
     */
34
    public function check(int $idSalesOrderItem): bool
35
    {
36
        $relationTransfer = $this->reader
37
            ->getPaymentCrefoPayOrderItemToCrefoPayApiLogByIdSalesOrderItemAndRequestTypeAndSuccessResult(
38
                $idSalesOrderItem,
39
                static::REQUEST_TYPE
40
            );
41
42
        return $relationTransfer->getIdPaymentCrefoPayOrderItemToCrefoPayApiLog() !== null;
43
    }
44
}
45