SubscriptionDeleteByTokenAction::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 5
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Finder\Http\Actions;
4
5
use Population\Manipule\Managers\SubscriptionManager;
6
use Illuminate\Contracts\Routing\ResponseFactory;
7
use Illuminate\Http\JsonResponse;
8
9
/**
10
 * Class SubscriptionDeleteByTokenAction.
11
 *
12
 * @package Finder\Http\Actions
13
 */
14 View Code Duplication
class SubscriptionDeleteByTokenAction
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /**
17
     * @var ResponseFactory
18
     */
19
    private $responseFactory;
20
21
    /**
22
     * @var SubscriptionManager
23
     */
24
    private $subscriptionManager;
25
26
    /**
27
     * SubscriptionDeleteByTokenAction constructor.
28
     *
29
     * @param ResponseFactory     $responseFactory
30
     * @param SubscriptionManager $subscriptionManager
31
     */
32
    public function __construct(ResponseFactory $responseFactory, SubscriptionManager $subscriptionManager)
33
    {
34
        $this->responseFactory = $responseFactory;
35
        $this->subscriptionManager = $subscriptionManager;
36
    }
37
38
    /**
39
     * @apiVersion        1.0.0
40
     * @api               {delete} /v1/subscriptions/:token Delete
41
     * @apiName           Delete
42
     * @apiGroup          Subscriptions
43
     * @apiHeader         {String} Accept application/json
44
     * @apiParam          {String{1..255}} :token Subscription token.
45
     * @apiSuccessExample {json} Success-Response:
46
     * HTTP/1.1 204 No Content
47
     */
48
49
    /**
50
     * Delete a subscription.
51
     *
52
     * @param  string $token
53
     * @return JsonResponse
54
     */
55
    public function __invoke(string $token): JsonResponse
56
    {
57
        $this->subscriptionManager->deleteByToken($token);
58
59
        return $this->responseFactory->json(null, JsonResponse::HTTP_NO_CONTENT);
60
    }
61
}
62