Failed Conditions
Push — master ( b2750a...eac8ff )
by Zbigniew
05:28
created

SlackController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 28
ccs 4
cts 8
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A commandAction() 0 9 1
A interactionAction() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the zibios/sharep.
7
 *
8
 * (c) Zbigniew Ślązak
9
 */
10
11
namespace App\Controller\Webhook;
12
13
use App\Slack\SlashCommand\CommandHelper;
14
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
15
use Symfony\Component\HttpFoundation\JsonResponse;
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\Routing\Annotation\Route;
19
20
/**
21
 * @Route("/webhook/slack", name="webhook_slack")
22
 */
23
class SlackController extends AbstractController
24
{
25
    /**
26
     * @Route("/command", name="_command", methods={"post"})
27
     */
28 3
    public function commandAction(
29
        Request $request,
30
        CommandHelper $commandHelper
31
    ): JsonResponse {
32 3
        $data = $request->request->all();
33 3
        $responseData = $commandHelper->handleWebhook($data);
34
35 3
        return new JsonResponse($responseData, Response::HTTP_OK);
36
    }
37
38
    /**
39
     * @Route("/interaction", name="_interaction")
40
     */
41
    public function interactionAction(
42
        Request $request,
43
        CommandHelper $commandHelper
44
    ): JsonResponse {
45
        $data = $request->request->all();
46
        $responseData = $commandHelper->handleWebhook($data);
47
48
        return new JsonResponse($responseData, Response::HTTP_OK);
49
    }
50
}
51