BotAuthHandler::suits()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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