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

SlackController::commandAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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