Passed
Pull Request — master (#58)
by
unknown
51:38
created

RemoveWishlistHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 2
b 0
f 0
nc 1
nop 2
dl 0
loc 7
rs 10
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