UserCallable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 7 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