Completed
Push — master ( c75724...87d358 )
by Razon
03:04
created

UserTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 10
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUser() 0 3 1
A getUser() 0 7 2
1
<?php
2
namespace App\Http\Api\Form;
3
4
use Yii;
5
use yii\web\IdentityInterface;
6
7
trait UserTrait
8
{
9
    /**
10
     * @var IdentityInterface
11
     */
12
    private $user;
13
14
    public function getUser(): ?IdentityInterface
15
    {
16
        if ($this->user === null) {
17
            $this->user = Yii::$app->getUser()->getIdentity();
18
        }
19
20
        return $this->user;
21
    }
22
23
    public function setUser(IdentityInterface $user)
24
    {
25
        $this->user = $user;
26
    }
27
}