IsCancelCallSuccessfulOmsCondition   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

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
    /**
15
     * @var string
16
     */
17
    protected const REQUEST_TYPE = 'cancel';
18
19
    /**
20
     * @var \SprykerEco\Zed\CrefoPay\Business\Reader\CrefoPayReaderInterface
21
     */
22
    protected $reader;
23
24
    /**
25
     * @param \SprykerEco\Zed\CrefoPay\Business\Reader\CrefoPayReaderInterface $reader
26
     */
27
    public function __construct(CrefoPayReaderInterface $reader)
28
    {
29
        $this->reader = $reader;
30
    }
31
32
    /**
33
     * @param int $idSalesOrderItem
34
     *
35
     * @return bool
36
     */
37
    public function check(int $idSalesOrderItem): bool
38
    {
39
        $relationTransfer = $this->reader
40
            ->getPaymentCrefoPayOrderItemToCrefoPayApiLogByIdSalesOrderItemAndRequestTypeAndSuccessResult(
41
                $idSalesOrderItem,
42
                static::REQUEST_TYPE,
43
            );
44
45
        return $relationTransfer->getIdPaymentCrefoPayOrderItemToCrefoPayApiLog() !== null;
46
    }
47
}
48