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

ZfcUserIdentity::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
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