Passed
Push — master ( fbc72e...fd2e1d )
by Alexey
04:39
created

WebHookController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A receiveUpdateAction() 0 17 2
1
<?php
2
3
namespace Skobkin\Bundle\PointToolsBundle\Controller\Telegram;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\HttpFoundation\JsonResponse;
7
use Symfony\Component\HttpFoundation\Request;
8
use unreal4u\TelegramAPI\Telegram\Types\Update;
9
10
/**
11
 * {@inheritdoc}
12
 */
13
class WebHookController extends Controller
14
{
15
    public function receiveUpdateAction(Request $request, $token)
16
    {
17
        if ($token !== $savedToken = $this->getParameter('telegram_token')) {
18
            throw $this->createNotFoundException();
19
        }
20
21
        $content = json_decode($request->getContent(), true);
22
23
        $update = new Update(
24
            $content,
25
            $this->get('logger')
26
        );
27
28
        $this->get('point_tools.telegram.update_processor')->process($update);
29
30
        return new JsonResponse('received');
31
    }
32
}
33