Completed
Pull Request — 1.x (#637)
by Daniel
14:10 queued 04:01
created

ZfcUserIdentity   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAuthService() 0 4 1
A __invoke() 0 8 2
A setAuthService() 0 5 1
1
<?php
2
3
namespace ZfcUser\View\Helper;
4
5
use Zend\View\Helper\AbstractHelper;
6
use Zend\Authentication\AuthenticationService;
7
8
class ZfcUserIdentity extends AbstractHelper
9
{
10
    /**
11
     * @var AuthenticationService
12
     */
13
    protected $authService;
14
15
    /**
16
     * __invoke
17
     *
18
     * @access public
19
     * @return \ZfcUser\Entity\UserInterface
20
     */
21
    public function __invoke()
22
    {
23
        if ($this->getAuthService()->hasIdentity()) {
24
            return $this->getAuthService()->getIdentity();
25
        } else {
26
            return false;
27
        }
28
    }
29
30
    /**
31
     * Get authService.
32
     *
33
     * @return AuthenticationService
34
     */
35
    public function getAuthService()
36
    {
37
        return $this->authService;
38
    }
39
40
    /**
41
     * Set authService.
42
     *
43
     * @param AuthenticationService $authService
44
     * @return \ZfcUser\View\Helper\ZfcUserIdentity
45
     */
46
    public function setAuthService(AuthenticationService $authService)
47
    {
48
        $this->authService = $authService;
49
        return $this;
50
    }
51
}
52