UserForm   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 26
ccs 0
cts 16
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUser() 0 3 1
A getUser() 0 7 2
A rules() 0 4 1
1
<?php
2
namespace App\Http\Api\Backend\Form;
3
4
use App\Form\BaseForm;
5
use App\Model\User;
6
use Yii;
7
8
abstract class UserForm extends BaseForm
9
{
10
    private $user;
11
12
    public function rules()
13
    {
14
        return [
15
            [['user'], 'required'],
16
        ];
17
    }
18
19
    /**
20
     * @return User
21
     */
22
    protected function getUser(): ?User
23
    {
24
        if ($this->user === null) {
25
            $this->user = Yii::$app->getUser()->getIdentity();
26
        }
27
28
        return $this->user;
29
    }
30
31
    public function setUser(User $user): void
32
    {
33
        $this->user = $user;
34
    }
35
}
36