Passed
Push — master ( 2820d8...14c982 )
by Vítězslav
05:52
created

Anonym::setSettingValue()   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
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 2
cp 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * Objekt Anonymního uživatele.
4
 *
5
 * @author    Vítězslav Dvořák <[email protected]>
6
 * @copyright 2009-2019 [email protected] (G)
7
 * 
8
 * @category User Classes
9
 * @package EasePHP
10
 * 
11
 * PHP 5
12
 * PHP 7
13
 */
14
15
namespace Ease;
16
17
/**
18
 * Anonymous User Class
19
 */
20
class Anonym extends Brick
21
{
22
    /**
23
     * Druh uživatele.
24
     *
25
     * @var string
26
     */
27
    public $type = 'anonymous';
28
29
    /**
30
     * Anonymní uživatel má vždy ID null.
31
     *
32
     * @var null
33
     */
34
    public $userID = null;
35
36
    /**
37
     * Indikátor přihlášení.
38
     *
39
     * @var bool
40
     */
41
    public $logged = false;
42
43
    /**
44
     * User Settings array
45
     *
46
     * @var array
47
     */
48
    public $settings = [];
49
50
    /**
51
     * Nastavení jména objektu uživatele.
52
     *
53
     * @param string $objectName vynucené jméno objektu
54
     *
55
     * @return string
56
     */
57 1
    public function setObjectName($objectName = null)
58
    {
59 1
        if (is_null($objectName) && isset($_SERVER['REMOTE_ADDR'])) {
60
            $name = parent::setObjectName(get_class($this).'@'.self::remoteToIdentity());
61
        } else {
62 1
            $name = parent::setObjectName($objectName);
63
        }
64 1
        return $name;
65
    }
66
67
    /**
68
     * Returns user identity with logname if logged
69
     *
70
     * @return string
71
     */
72
    public static function remoteToIdentity()
73
    {
74
        if (isset($_SERVER['REMOTE_USER'])) {
75
            $identity = $_SERVER['REMOTE_ADDR'].' ['.$_SERVER['REMOTE_USER'].']';
76
        } else {
77
            $identity = $_SERVER['REMOTE_ADDR'];
78
        }
79
        return $identity;
80
    }
81
82
    /**
83
     * Anonym má level.
84
     *
85
     * @return int
86
     */
87
    public function getUserLevel()
88
    {
89
        return -1;
90
    }
91
92
    /**
93
     * Anonym nema ID.
94
     */
95
    public function getUserID()
96
    {
97
        return;
98
    }
99
100
    /**
101
     * Anonym nemá login.
102
     */
103
    public function getUserLogin()
104
    {
105
        return;
106
    }
107
108
    /**
109
     * Anonym nemůže být přihlášený.
110
     *
111
     * @return bool FALSE
112
     */
113
    public function isLogged()
114
    {
115
        return $this->logged;
116
    }
117
118
    /**
119
     * Anonym nemá nastavení.
120
     *
121
     * @param string $settingName jméno klíče nastavení
122
     */
123
    public function getSettingValue($settingName = null)
124
    {
125
        return;
126
    }
127
128
    /**
129
     * Nastaví položku nastavení.
130
     *
131
     * @param string $settingName  klíčové slovo pro nastavení
132
     * @param mixed  $settingValue hodnota nastavení
133
     */
134
    public function setSettingValue($settingName, $settingValue)
135
    {
136
        $this->settings[$settingName] = $settingValue;
137
    }
138
139
    
140
    
141
    /**
142
     * Anonym nemá mail.
143
     */
144
    public function getUserEmail()
145
    {
146
        return;
147
    }
148
149
    /**
150
     * Fake permissions.
151
     *
152
     * @param string $permKeyword permission keyword
153
     */
154
    public function getPermission($permKeyword = null)
0 ignored issues
show
Unused Code introduced by
The parameter $permKeyword is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

154
    public function getPermission(/** @scrutinizer ignore-unused */ $permKeyword = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
155
    {
156
        return;
157
    }
158
159
    /**
160
     * Just fake.
161
     *
162
     * @return bool true - always logged off
163
     */
164
    public function logout()
165
    {
166
        $this->userID = null;
167
168
        return true;
169
    }
170
}
171