InitController::actionTelegram()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace app\commands;
4
5
use app\core\models\User;
6
use app\core\services\TelegramService;
7
use app\core\traits\ServiceTrait;
8
use yii\console\Controller;
9
use yii\console\ExitCode;
10
use yii\helpers\Url;
11
12
class InitController extends Controller
13
{
14
    use ServiceTrait;
15
16
    public function actionTelegram(string $url = '/v1/telegram/hook'): int
17
    {
18
        $url = Url::to($url, true);
19
        TelegramService::newClient()->setWebHook($url);
20
        $this->stdout("Telegram set Webhook url success!: {$url}\n");
21
        return ExitCode::OK;
22
    }
23
24
    /**
25
     * @param  int  $userId
26
     * @throws \app\core\exceptions\InvalidArgumentException
27
     * @throws \yii\db\Exception
28
     */
29
    public function actionUserData(int $userId)
30
    {
31
        $this->userService->createUserAfterInitData(User::findOne($userId));
32
        $this->stdout("User Account and Category init success! \n");
33
    }
34
}
35