Completed
Pull Request — master (#16)
by Flo
07:29
created

User   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 21
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
A isLoggedIn() 0 4 1
A get() 0 6 1
1
<?php
2
/**
3
 * Class User | User.php
4
 * @package Faulancer\View\Helper
5
 * @author  Florian Knapp <[email protected]>
6
 */
7
namespace Faulancer\View\Helper;
8
9
use Faulancer\Service\AuthenticatorService;
10
use Faulancer\Service\SessionManagerService;
11
use Faulancer\Session\SessionManager;
12
use Faulancer\View\AbstractViewHelper;
13
14
/**
15
 * Class User
16
 */
17
class User extends AbstractViewHelper
18
{
19
20
    public function __invoke()
21
    {
22
        return $this;
23
    }
24
25
    public function isLoggedIn()
26
    {
27
        return $this->getServiceLocator()->get(SessionManagerService::class)->get('user') > 0;
28
    }
29
30
    public function get()
31
    {
32
        /** @var AuthenticatorService $authenticator */
33
        $authenticator = $this->getServiceLocator()->get(AuthenticatorService::class);
34
        return $authenticator->getUserFromSession();
35
    }
36
37
}