ExportSelectedProductsFromWishlistToPdfHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __invoke() 0 5 1
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusWishlistPlugin\CommandHandler\Wishlist;
12
13
use BitBag\SyliusWishlistPlugin\Command\Wishlist\ExportSelectedProductsFromWishlistToPdfInterface;
14
use BitBag\SyliusWishlistPlugin\Services\Exporter\WishlistToPdfExporterInterface;
15
use Symfony\Component\HttpFoundation\RequestStack;
16
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
17
18
final class ExportSelectedProductsFromWishlistToPdfHandler implements MessageHandlerInterface
19
{
20
    private RequestStack $request;
21
22
    private WishlistToPdfExporterInterface $exporterWishlistToPdf;
23
24
    public function __construct(
25
        RequestStack $request,
26
        WishlistToPdfExporterInterface $exporterWishlistToPdf
27
    ) {
28
        $this->request = $request;
29
        $this->exporterWishlistToPdf = $exporterWishlistToPdf;
30
    }
31
32
    public function __invoke(ExportSelectedProductsFromWishlistToPdfInterface $exportSelectedProductsFromWishlistToPdf): void
33
    {
34
        $wishlistProducts = $exportSelectedProductsFromWishlistToPdf->getWishlistProducts();
35
        $this->exporterWishlistToPdf
36
            ->createModelToPdfAndExportToPdf($wishlistProducts, $this->request->getCurrentRequest());
0 ignored issues
show
Bug introduced by
It seems like $wishlistProducts can also be of type null; however, parameter $wishlistProducts of BitBag\SyliusWishlistPlu...elToPdfAndExportToPdf() does only seem to accept Doctrine\Common\Collections\Collection, maybe add an additional type check? ( Ignorable by Annotation )

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

36
            ->createModelToPdfAndExportToPdf(/** @scrutinizer ignore-type */ $wishlistProducts, $this->request->getCurrentRequest());
Loading history...
Bug introduced by
It seems like $this->request->getCurrentRequest() can also be of type null; however, parameter $request of BitBag\SyliusWishlistPlu...elToPdfAndExportToPdf() does only seem to accept Symfony\Component\HttpFoundation\Request, maybe add an additional type check? ( Ignorable by Annotation )

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

36
            ->createModelToPdfAndExportToPdf($wishlistProducts, /** @scrutinizer ignore-type */ $this->request->getCurrentRequest());
Loading history...
37
    }
38
}
39