MyInfoForm   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 17
c 1
b 0
f 0
dl 0
loc 25
ccs 0
cts 22
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPermissions() 0 7 1
A handleInternal() 0 13 1
1
<?php
2
namespace App\Http\Api\Backend\Form;
3
4
use Yii;
5
6
class MyInfoForm extends UserForm
7
{
8
    protected function handleInternal()
9
    {
10
        $user = $this->getUser();
11
        return [
12
            'id' => $user->id,
13
            'username' => $user->username,
14
            'name' => $user->name,
15
            'first_name' => $user->first_name,
16
            'last_name' => $user->last_name,
17
            'email' => $user->email,
18
            'avatar' => $user->avatar,
19
            'language' => $user->language,
0 ignored issues
show
Bug Best Practice introduced by
The property language does not exist on App\Model\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
20
            'permissions' => $this->getPermissions(),
21
        ];
22
    }
23
24
    protected function getPermissions()
25
    {
26
        $user = $this->getUser();
27
        $auth = Yii::$app->getAuthManager();
28
        $permissions = $auth->getPermissionsByUser($user->id);
29
        $names = array_column($permissions, 'name');
30
        return $names;
31
    }
32
}
33