BotAuthHandler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A suits() 0 3 2
A auth() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zored\Telegram\Madeline\Auth\Handler;
6
7
use danog\MadelineProto\MTProto;
8
use Zored\Telegram\Madeline\Config\Auth\AuthConfigInterface;
9
use Zored\Telegram\Madeline\Config\Auth\BotAuth;
10
11
/**
12
 * @property BotAuth $config
13
 */
14
class BotAuthHandler extends AbstractAuthHandler
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function suits(AuthConfigInterface $config): bool
20
    {
21
        return parent::suits($config) || $config instanceof BotAuth;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function auth(MTProto $proto): void
28
    {
29
        parent::auth($proto);
30
31
        if ($this->isAuthorized($proto)) {
32
            return;
33
        }
34
35
        $proto->bot_login($this->config->getToken());
36
    }
37
}
38