Passed
Pull Request — master (#58)
by
unknown
03:30
created

RemoveWishlistHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 5 1
A __construct() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitBag\SyliusWishlistPlugin\CommandHandler\Wishlist;
6
7
use BitBag\SyliusWishlistPlugin\Command\Wishlist\RemoveWishlist;
8
use BitBag\SyliusWishlistPlugin\Repository\WishlistRepositoryInterface;
9
use BitBag\SyliusWishlistPlugin\Updater\WishlistUpdaterInterface;
10
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
11
12
final class RemoveWishlistHandler implements MessageHandlerInterface
13
{
14
    private WishlistRepositoryInterface $wishlistRepository;
15
16
    private WishlistUpdaterInterface $wishlistUpdater;
17
18
    public function __construct(
19
        WishlistRepositoryInterface $wishlistRepository,
20
        WishlistUpdaterInterface $wishlistUpdater
21
    )
22
    {
23
        $this->wishlistRepository = $wishlistRepository;
24
        $this->wishlistUpdater = $wishlistUpdater;
25
    }
26
27
    public function __invoke(RemoveWishlist $removeWishlist)
28
    {
29
        $wishlist = $this->wishlistRepository->findByToken($removeWishlist->getWishlistTokenValue());
30
31
        $this->wishlistUpdater->removeWishlist($wishlist);
0 ignored issues
show
Bug introduced by
It seems like $wishlist can also be of type null; however, parameter $wishlist of BitBag\SyliusWishlistPlu...rface::removeWishlist() does only seem to accept BitBag\SyliusWishlistPlu...ntity\WishlistInterface, 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

31
        $this->wishlistUpdater->removeWishlist(/** @scrutinizer ignore-type */ $wishlist);
Loading history...
32
    }
33
}
34