Completed
Push — master ( 6252ff...b42479 )
by Adam
80:52 queued 68:32
created

UserCallable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 29
ccs 5
cts 6
cp 0.8333
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 8 2
1
<?php
2
/**
3
 * UserCallable.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec http://www.ipublikuj.eu
8
 * @package        iPublikuj:DoctrineBlameable!
9
 * @subpackage     Security
10
 * @since          1.0.0
11
 *
12
 * @date           05.01.16
13
 */
14
15
namespace IPub\DoctrineBlameable\Security;
16
17
use Nette;
18
use Nette\Security as NS;
19
20
/**
21
 * Doctrine blameable default user callable
22
 *
23
 * @package        iPublikuj:DoctrineBlameable!
24
 * @subpackage     Security
25
 *
26
 * @author         Adam Kadlec <[email protected]>
27
 */
28
class UserCallable
29 1
{
30
	/**
31
	 * Define class name
32
	 */
33
	const CLASS_NAME = __CLASS__;
34
35
	/**
36
	 * @var NS\User
37
	 */
38
	private $user;
39
40
	public function __construct(NS\User $user)
41
	{
42 1
		$this->user = $user;
43 1
	}
44
45
	/**
46
	 * @return mixed
47
	 */
48
	public function __invoke()
49
	{
50 1
		if ($this->user->isLoggedIn()) {
51
			return $this->user->getId();
52
		}
53
54 1
		return NULL;
55
	}
56
}
57