IsDoneReceivedOmsCondition::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
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
use SprykerEco\Zed\CrefoPay\CrefoPayConfig;
12
13
class IsDoneReceivedOmsCondition implements CrefoPayOmsConditionInterface
14
{
15
    /**
16
     * @var \SprykerEco\Zed\CrefoPay\Business\Reader\CrefoPayReaderInterface
17
     */
18
    protected $reader;
19
20
    /**
21
     * @var \SprykerEco\Zed\CrefoPay\CrefoPayConfig
22
     */
23
    protected $config;
24
25
    /**
26
     * @param \SprykerEco\Zed\CrefoPay\Business\Reader\CrefoPayReaderInterface $reader
27
     * @param \SprykerEco\Zed\CrefoPay\CrefoPayConfig $config
28
     */
29
    public function __construct(
30
        CrefoPayReaderInterface $reader,
31
        CrefoPayConfig $config
32
    ) {
33
        $this->reader = $reader;
34
        $this->config = $config;
35
    }
36
37
    /**
38
     * @param int $idSalesOrderItem
39
     *
40
     * @return bool
41
     */
42
    public function check(int $idSalesOrderItem): bool
43
    {
44
        $relationTransfer = $this->reader
45
            ->getPaymentCrefoPayOrderItemToCrefoPayNotificationByIdSalesOrderItemAndTransactionStatus(
46
                $idSalesOrderItem,
47
                $this->config->getNotificationTransactionStatusDone(),
48
            );
49
50
        return $relationTransfer->getIdPaymentCrefoPayOrderItemToCrefoPayNotification() !== null;
51
    }
52
}
53