Passed
Push — master ( 7a2782...032b3c )
by Christian
11:03
created

CartMergedSubscriber::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Storefront\Event;
4
5
use Shopware\Core\Checkout\Cart\Event\CartMergedEvent;
6
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
7
use Symfony\Component\HttpFoundation\Session\Session;
8
use Symfony\Contracts\Translation\TranslatorInterface;
9
10
class CartMergedSubscriber implements EventSubscriberInterface
11
{
12
    /**
13
     * @var Session
14
     */
15
    private $session;
16
17
    /**
18
     * @var TranslatorInterface
19
     */
20
    private $translator;
21
22
    public function __construct(
23
        Session $session,
24
        TranslatorInterface $translator
25
    ) {
26
        $this->session = $session;
27
        $this->translator = $translator;
28
    }
29
30
    public static function getSubscribedEvents(): array
31
    {
32
        return [
33
            CartMergedEvent::class => 'addCartMergedNoticeFlash',
34
        ];
35
    }
36
37
    public function addCartMergedNoticeFlash(CartMergedEvent $event): void
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

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

37
    public function addCartMergedNoticeFlash(/** @scrutinizer ignore-unused */ CartMergedEvent $event): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39
        $this->session->getFlashBag()->add('info', $this->translator->trans('checkout.cart-merged-hint'));
40
    }
41
}
42