Completed
Push — develop ( 059b46...8f56e3 )
by Michele
02:21
created

Webhook   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zanzara\UpdateMode;
6
7
use Zanzara\Telegram\Type\Update;
8
9
/**
10
 *
11
 */
12
class Webhook extends BaseWebhook
13
{
14
15
    public function run()
16
    {
17
        $token = $this->resolveTokenFromPath($_SERVER['REQUEST_URI'] ?? '');
18
        if (!$this->isWebhookAuthorized($token)) {
19
            http_response_code(403);
20
            $this->logger->errorNotAuthorized();
21
        } else {
22
            $json = file_get_contents($this->config->getUpdateStream());
23
            /** @var Update $update */
24
            $update = $this->zanzaraMapper->mapJson($json, Update::class);
25
            $this->processUpdate($update);
26
        }
27
    }
28
}
29