InitController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A actionUserData() 0 4 1
A actionTelegram() 0 6 1
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