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

Webhook::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 11
rs 10
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