checkIfApprovedNotificationReceived()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 2
nc 2
nop 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\FirstData\Business\Checker;
9
10
use SprykerEco\Zed\FirstData\Persistence\FirstDataRepositoryInterface;
11
12
class FirstDataNotificationChecker implements FirstDataNotificationCheckerInterface
13
{
14
    protected const NOTIFICATION_STATUS_APPROVED = 'APPROVED';
15
16
    /**
17
     * @var \SprykerEco\Zed\FirstData\Persistence\FirstDataRepositoryInterface
18
     */
19
    protected $firstDataRepository;
20
21
    /**
22
     * @param \SprykerEco\Zed\FirstData\Persistence\FirstDataRepositoryInterface $firstDataRepository
23
     */
24
    public function __construct(FirstDataRepositoryInterface $firstDataRepository)
25
    {
26
        $this->firstDataRepository = $firstDataRepository;
27
    }
28
29
    /**
30
     * @param string $transactionId
31
     *
32
     * @return bool
33
     */
34
    public function checkIfApprovedNotificationReceived(string $transactionId): bool
35
    {
36
        $firstDataNotification = $this->firstDataRepository->findPaymentFirstDataNotificationByTransactionId($transactionId);
37
38
        if (!$firstDataNotification) {
39
            return false;
40
        }
41
42
        return $firstDataNotification->getStatus() === static::NOTIFICATION_STATUS_APPROVED;
43
    }
44
}
45