Passed
Push — master ( a97a13...4050b6 )
by Gabor
03:36
created

GetCurrentUserHelper::getOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.2
6
 *
7
 * @copyright 2012 - 2019 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Renderer\Helper;
15
16
use WebHemi\Acl\ServiceInterface as AclInterface;
17
use WebHemi\Auth\ServiceInterface as AuthInterface;
18
use WebHemi\Configuration\ServiceInterface as ConfigurationInterface;
19
use WebHemi\Data\Entity\ResourceEntity;
20
use WebHemi\Data\Entity\ApplicationEntity;
21
use WebHemi\Data\Entity\UserEntity;
22
use WebHemi\Data\Storage\ResourceStorage;
23
use WebHemi\Data\Storage\ApplicationStorage;
24
use WebHemi\Environment\ServiceInterface as EnvironmentInterface;
25
use WebHemi\Renderer\HelperInterface;
26
27
/**
28
 * Class GetCurrentUserHelper
29
 */
30
class GetCurrentUserHelper implements HelperInterface
31
{
32
    /**
33
     * @var AuthInterface
34
     */
35
    private $authAdapter;
36
37
    /**
38
     * Should return the name of the helper.
39
     *
40
     * @return             string
41
     * @codeCoverageIgnore - plain text
42
     */
43
    public static function getName() : string
44
    {
45
        return 'getCurrentUser';
46
    }
47
48
    /**
49
     * Should return the name of the helper.
50
     *
51
     * @return             string
52
     * @codeCoverageIgnore - plain text
53
     */
54
    public static function getDefinition() : string
55
    {
56
        return '{% set user = getCurrentUser() %}';
57
    }
58
59
    /**
60
     * Should return a description text.
61
     *
62
     * @return             string
63
     * @codeCoverageIgnore - plain text
64
     */
65
    public static function getDescription() : string
66
    {
67
        return 'Returns the current logged in user information.';
68
    }
69
70
    /**
71
     * Gets helper options for the render.
72
     *
73
     * @return             array
74
     * @codeCoverageIgnore - empty array
75
     */
76
    public static function getOptions() : array
77
    {
78
        return [];
79
    }
80
81
    /**
82
     * IsAllowedHelper constructor.
83
     *
84
     * @param AuthInterface $authAdapter
85
     */
86
    public function __construct(
87
        AuthInterface $authAdapter
88
    ) {
89
        $this->authAdapter = $authAdapter;
90
    }
91
92
    /**
93
     * A renderer helper should be called with its name.
94
     *
95
     * @return null|UserEntity
96
     */
97
    public function __invoke() : ? UserEntity
98
    {
99
        /**
100
         * @var UserEntity $userEntity
101
         */
102
        return $this->authAdapter->getIdentity();
103
    }
104
}
105