CompanyApiLogin   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 6
c 1
b 0
f 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getLoginInfo() 0 7 1
1
<?php
2
namespace SimpleCMS\Company\Packages;
3
4
use Illuminate\Support\Facades\Auth;
5
use Illuminate\Support\Facades\Hash;
6
use SimpleCMS\Company\Models\CompanyAccount;
7
use SimpleCMS\Framework\Exceptions\SimpleException;
8
use SimpleCMS\Framework\Packages\Finger\Finger;
9
use Symfony\Component\HttpFoundation\RedirectResponse;
10
11
12
class CompanyApiLogin
13
{
14
    /**
15
     * 获取登录token及基础信息
16
     * @param \SimpleCMS\Company\Models\CompanyAccount $account
17
     * @return array
18
     */
19
    public static function getLoginInfo(CompanyAccount $account): array
20
    {
21
        $token = $account->createToken('company_api');
22
        return [
23
            'token' => $token->plainTextToken,
24
            'finger' => Finger::getFinger(),
25
            'user' => (new CompanyAuthenticatable)->getAccount($account)
26
        ];
27
    }
28
29
}