IsRefundCallSuccessfulOmsCondition::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 IsRefundCallSuccessfulOmsCondition implements CrefoPayOmsConditionInterface
13
{
14
    /**
15
     * @var string
16
     */
17
    protected const REQUEST_TYPE = 'refund';
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