Failed Conditions
Push — master ( cdc595...f2bb18 )
by Adrien
02:12
created

CurrentUser::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Model;
6
7
/**
8
 * Tiny bit dirty way to easily pass current user from app to Felix
9
 */
10
final class CurrentUser
11
{
12
    /**
13
     * @var null|User
14
     */
15
    private static $currentUser = null;
16
17
    /**
18
     * Set currently logged in user
19
     *
20
     * @param null|User $user
21
     */
22 1
    public static function set(?User $user): void
23
    {
24 1
        self::$currentUser = $user;
25 1
    }
26
27
    /**
28
     * Returns currently logged user or null
29
     *
30
     * @return null|User
31
     */
32 1
    public static function get(): ?User
33
    {
34 1
        return self::$currentUser;
35
    }
36
}
37