RemoveWishlistAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 8 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\Controller\Action\ApiPlatform;
12
13
use BitBag\SyliusWishlistPlugin\Command\Wishlist\RemoveWishlist;
14
use Symfony\Component\HttpFoundation\JsonResponse;
15
use Symfony\Component\HttpFoundation\Request;
16
use Symfony\Component\HttpFoundation\Response;
17
use Symfony\Component\Messenger\MessageBusInterface;
18
19
final class RemoveWishlistAction
20
{
21
    private MessageBusInterface $messageBus;
22
23
    public function __construct(MessageBusInterface $messageBus)
24
    {
25
        $this->messageBus = $messageBus;
26
    }
27
28
    public function __invoke(Request $request): JsonResponse
29
    {
30
        $wishlistToken = (string) $request->attributes->get('token');
31
32
        $removeWishlist = new RemoveWishlist($wishlistToken);
33
        $this->messageBus->dispatch($removeWishlist);
34
35
        return new JsonResponse([], Response::HTTP_NO_CONTENT);
36
    }
37
}
38