Webhook::run()   A
last analyzed

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
    /**
16
     * @inheritDoc
17
     */
18
    public function run()
19
    {
20
        $token = $this->resolveTokenFromPath($_SERVER['REQUEST_URI'] ?? '');
21
        if (!$this->isWebhookAuthorized($token)) {
22
            http_response_code(403);
23
            $this->logger->errorNotAuthorized();
24
        } else {
25
            $json = file_get_contents($this->config->getUpdateStream());
26
            /** @var Update $update */
27
            $update = $this->zanzaraMapper->mapJson($json, Update::class);
28
            $this->processUpdate($update);
29
        }
30
    }
31
}
32