Passed
Push — master ( c5706a...747b7a )
by
unknown
17:47 queued 11:33
created

RefundPaymentGeneratedAutoCompleteListener   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 13 2
A __construct() 0 8 1
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * You can find more information about us on https://bitbag.io and write us
7
 * an email on [email protected].
8
 */
9
10
declare(strict_types=1);
11
12
namespace BitBag\SyliusMolliePlugin\EventListener;
13
14
use BitBag\SyliusMolliePlugin\Factory\MollieGatewayFactory;
15
use BitBag\SyliusMolliePlugin\Repository\PaymentMethodRepositoryInterface;
16
use Doctrine\Common\Persistence\ObjectRepository;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Persistence\ObjectRepository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Sylius\Component\Core\Model\PaymentMethodInterface;
18
use Sylius\RefundPlugin\Entity\RefundPaymentInterface;
19
use Sylius\RefundPlugin\Event\RefundPaymentGenerated;
20
use Sylius\RefundPlugin\StateResolver\RefundPaymentCompletedStateApplierInterface;
21
22
final class RefundPaymentGeneratedAutoCompleteListener
23
{
24
    /** @var ObjectRepository */
25
    private $refundPaymentRepository;
26
27
    /** @var RefundPaymentCompletedStateApplierInterface */
28
    private $refundPaymentCompletedStateApplier;
29
30
    /** @var PaymentMethodRepositoryInterface */
31
    private $paymentMethodRepository;
32
33
    public function __construct(
34
        ObjectRepository $refundPaymentInterface,
35
        RefundPaymentCompletedStateApplierInterface $refundPaymentCompletedStateApplier,
36
        PaymentMethodRepositoryInterface $paymentMethodRepository
37
    ) {
38
        $this->refundPaymentRepository = $refundPaymentInterface;
39
        $this->refundPaymentCompletedStateApplier = $refundPaymentCompletedStateApplier;
40
        $this->paymentMethodRepository = $paymentMethodRepository;
41
    }
42
43
    public function __invoke(RefundPaymentGenerated $refundPaymentGenerated): void
44
    {
45
        /** @var PaymentMethodInterface $paymentMethod */
46
        $paymentMethod = $this->paymentMethodRepository->find($refundPaymentGenerated->paymentMethodId());
47
48
        if (MollieGatewayFactory::FACTORY_NAME !== $paymentMethod->getGatewayConfig()->getFactoryName()) {
0 ignored issues
show
Deprecated Code introduced by
The function Payum\Core\Model\Gateway...rface::getFactoryName() has been deprecated: since 1.3.3 will be removed in 2.0. set factory option inside the config ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

48
        if (MollieGatewayFactory::FACTORY_NAME !== /** @scrutinizer ignore-deprecated */ $paymentMethod->getGatewayConfig()->getFactoryName()) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
49
            return;
50
        }
51
52
        /** @var RefundPaymentInterface $refundPayment */
53
        $refundPayment = $this->refundPaymentRepository->find($refundPaymentGenerated->id());
54
55
        $this->refundPaymentCompletedStateApplier->apply($refundPayment);
56
    }
57
}