UserCallable::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Zenify
7
 * Copyright (c) 2012 Tomas Votruba (http://tomasvotruba.cz)
8
 */
9
10
namespace Zenify\DoctrineBehaviors\Blameable;
11
12
use Nette\Security\User;
13
14
15
final class UserCallable
16
{
17
18
	/**
19
	 * @var User
20
	 */
21
	private $user;
22
23
24 2
	public function __construct(User $user)
25
	{
26 2
		$this->user = $user;
27 2
	}
28
29
30
	/**
31
	 * @return mixed
32
	 */
33 1
	public function __invoke()
34
	{
35 1
		if ($this->user->isLoggedIn()) {
36 1
			return $this->user->getId();
37
		}
38 1
		return NULL;
39
	}
40
41
}
42