SessionConfigNode::toArray()   F
last analyzed

Complexity

Conditions 12
Paths 2048

Size

Total Lines 43
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 156

Importance

Changes 0
Metric Value
cc 12
eloc 24
nc 2048
nop 0
dl 0
loc 43
ccs 0
cts 37
cp 0
crap 156
rs 2.8
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * \AppserverIo\Appserver\Core\Api\Node\SessionConfigNode
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/appserver
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Appserver\Core\Api\Node;
22
23
use AppserverIo\Description\Annotations as DI;
24
use AppserverIo\Description\Api\Node\AbstractNode;
25
use AppserverIo\Psr\Servlet\ServletSessionInterface;
26
27
/**
28
 * DTO to transfer a session configuration.
29
 *
30
 * @author    Tim Wagner <[email protected]>
31
 * @copyright 2015 TechDivision GmbH <[email protected]>
32
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
 * @link      https://github.com/appserver-io/appserver
34
 * @link      http://www.appserver.io
35
 */
36
class SessionConfigNode extends AbstractNode implements SessionConfigNodeInterface
37
{
38
39
    /**
40
     * The session name information.
41
     *
42
     * @var \AppserverIo\Appserver\Core\Api\Node\SessionNameNode
43
     * @DI\Mapping(nodeName="session-name", nodeType="AppserverIo\Appserver\Core\Api\Node\SessionNameNode")
44
     */
45
    protected $sessionName;
46
47
    /**
48
     * The session file prefix information.
49
     *
50
     * @var \AppserverIo\Appserver\Core\Api\Node\SessionFilePrefixNode
51
     * @DI\Mapping(nodeName="session-file-prefix", nodeType="AppserverIo\Appserver\Core\Api\Node\SessionFilePrefixNode")
52
     */
53
    protected $sessionFilePrefix;
54
55
    /**
56
     * The session save path information.
57
     *
58
     * @var \AppserverIo\Appserver\Core\Api\Node\SessionSavePathNode
59
     * @DI\Mapping(nodeName="session-save-path", nodeType="AppserverIo\Appserver\Core\Api\Node\SessionSavePathNode")
60
     */
61
    protected $sessionSavePath;
62
63
    /**
64
     * The garbage collection probability information.
65
     *
66
     * @var \AppserverIo\Appserver\Core\Api\Node\GarbageCollectionProbabilityNode
67
     * @DI\Mapping(nodeName="garbage-collection-probability", nodeType="AppserverIo\Appserver\Core\Api\Node\GarbageCollectionProbabilityNode")
68
     */
69
    protected $garbageCollectionProbability;
70
71
    /**
72
     * The session maximum age information.
73
     *
74
     * @var \AppserverIo\Appserver\Core\Api\Node\SessionMaximumAgeNode
75
     * @DI\Mapping(nodeName="session-maximum-age", nodeType="AppserverIo\Appserver\Core\Api\Node\SessionMaximumAgeNode")
76
     */
77
    protected $sessionMaximumAge;
78
79
    /**
80
     * The session inactivity timeout information.
81
     *
82
     * @var \AppserverIo\Appserver\Core\Api\Node\SessionInactivityTimeoutNode
83
     * @DI\Mapping(nodeName="session-inactivity-timeout", nodeType="AppserverIo\Appserver\Core\Api\Node\SessionInactivityTimeoutNode")
84
     */
85
    protected $sessionInactivityTimeout;
86
87
    /**
88
     * The session cookie lifetime information.
89
     *
90
     * @var \AppserverIo\Appserver\Core\Api\Node\SessionCookieLifetimeNode
91
     * @DI\Mapping(nodeName="session-cookie-lifetime", nodeType="AppserverIo\Appserver\Core\Api\Node\SessionCookieLifetimeNode")
92
     */
93
    protected $sessionCookieLifetime;
94
95
    /**
96
     * The session cookie domain information.
97
     *
98
     * @var \AppserverIo\Appserver\Core\Api\Node\SessionCookieDomainNode
99
     * @DI\Mapping(nodeName="session-cookie-domain", nodeType="AppserverIo\Appserver\Core\Api\Node\SessionCookieDomainNode")
100
     */
101
    protected $sessionCookieDomain;
102
103
    /**
104
     * The session cookie path information.
105
     *
106
     * @var \AppserverIo\Appserver\Core\Api\Node\SessionCookiePathNode
107
     * @DI\Mapping(nodeName="session-cookie-path", nodeType="AppserverIo\Appserver\Core\Api\Node\SessionCookiePathNode")
108
     */
109
    protected $sessionCookiePath;
110
111
    /**
112
     * The session cookie secure information.
113
     *
114
     * @var \AppserverIo\Appserver\Core\Api\Node\SessionCookieSecureNode
115
     * @DI\Mapping(nodeName="session-cookie-secure", nodeType="AppserverIo\Appserver\Core\Api\Node\SessionCookieSecureNode")
116
     */
117
    protected $sessionCookieSecure;
118
119
    /**
120
     * The session HTTP only information.
121
     *
122
     * @var \AppserverIo\Appserver\Core\Api\Node\SessionCookieHttpOnlyNode
123
     * @DI\Mapping(nodeName="session-cookie-http-only", nodeType="AppserverIo\Appserver\Core\Api\Node\SessionCookieHttpOnlyNode")
124
     */
125
    protected $sessionCookieHttpOnly;
126
127
    /**
128
     * Return's the session name information.
129
     *
130
     * @return \AppserverIo\Appserver\Core\Api\Node\SessionNameNode The session name information
131
     */
132
    public function getSessionName()
133
    {
134
        return $this->sessionName;
135
    }
136
137
    /**
138
     * Return's the session file prefix information.
139
     *
140
     * @return \AppserverIo\Appserver\Core\Api\Node\SessionFilePrefixNode The session file prefix information
141
     */
142
    public function getSessionFilePrefix()
143
    {
144
        return $this->sessionFilePrefix;
145
    }
146
147
    /**
148
     * Return's the session save path information.
149
     *
150
     * @return \AppserverIo\Appserver\Core\Api\Node\SessionSavePathNode The session save path information
151
     */
152
    public function getSessionSavePath()
153
    {
154
        return $this->sessionSavePath;
155
    }
156
157
    /**
158
     * Return's the garbage collection probability information.
159
     *
160
     * @return \AppserverIo\Appserver\Core\Api\Node\GarbageCollectionProbabilityNode The garbage collection probability information
161
     */
162
    public function getGarbageCollectionProbability()
163
    {
164
        return $this->garbageCollectionProbability;
165
    }
166
167
    /**
168
     * Return's the session maixmum age information.
169
     *
170
     * @return \AppserverIo\Appserver\Core\Api\Node\SessionMaximumAgeNode The session maximum age information
171
     */
172
    public function getSessionMaximumAge()
173
    {
174
        return $this->sessionMaximumAge;
175
    }
176
177
    /**
178
     * Return's the session inactivity timeout information.
179
     *
180
     * @return \AppserverIo\Appserver\Core\Api\Node\SessionInactivityTimeoutNode The session inativity timeout information
181
     */
182
    public function getSessionInactivityTimeout()
183
    {
184
        return $this->sessionInactivityTimeout;
185
    }
186
187
    /**
188
     * Return's the session cookie lifetime information.
189
     *
190
     * @return \AppserverIo\Appserver\Core\Api\Node\SessionCookieLifetimeNode The session cookie lifetime information
191
     */
192
    public function getSessionCookieLifetime()
193
    {
194
        return $this->sessionCookieLifetime;
195
    }
196
197
    /**
198
     * Return's the session cookie domain information.
199
     *
200
     * @return \AppserverIo\Appserver\Core\Api\Node\SessionCookieDomainNode The session cookie domain information
201
     */
202
    public function getSessionCookieDomain()
203
    {
204
        return $this->sessionCookieDomain;
205
    }
206
207
    /**
208
     * Return's the session cookie path information.
209
     *
210
     * @return \AppserverIo\Appserver\Core\Api\Node\SessionCookiePathNode The session cookie path information
211
     */
212
    public function getSessionCookiePath()
213
    {
214
        return $this->sessionCookiePath;
215
    }
216
217
    /**
218
     * Return's the session cookie secure information.
219
     *
220
     * @return \AppserverIo\Appserver\Core\Api\Node\SessionCookieSecureNode The session cookie secure information
221
     */
222
    public function getSessionCookieSecure()
223
    {
224
        return $this->sessionCookieSecure;
225
    }
226
227
    /**
228
     * Return's the session cookie HTTP only information.
229
     *
230
     * @return \AppserverIo\Appserver\Core\Api\Node\SessionCookieHttpOnlyNode The session cookie HTTP only information
231
     */
232
    public function getSessionCookieHttpOnly()
233
    {
234
        return $this->sessionHttpOnly;
0 ignored issues
show
Bug introduced by
The property sessionHttpOnly does not exist on AppserverIo\Appserver\Co...\Node\SessionConfigNode. Did you mean sessionCookieHttpOnly?
Loading history...
235
    }
236
237
    /**
238
     * Returns the session configuration as associative array.
239
     *
240
     * @return array The array with the session configuration
241
     */
242
    public function toArray()
243
    {
244
245
        // initialize the array with the session configuration
246
        $sessionConfiguration = array();
247
248
        // query whether or not a value has been available in the deployment descriptor
249
        if ($sessionName = $this->getSessionName()) {
250
            $sessionConfiguration[ServletSessionInterface::SESSION_NAME] = (string) $sessionName;
251
        }
252
        if ($sessionSavePath = $this->getSessionSavePath()) {
253
            $sessionConfiguration[ServletSessionInterface::SESSION_SAVE_PATH] = (string) $sessionSavePath;
254
        }
255
        if ($sessionMaximumAge = $this->getSessionMaximumAge()) {
256
            $sessionConfiguration[ServletSessionInterface::SESSION_MAXIMUM_AGE] = (string) $sessionMaximumAge;
257
        }
258
        if ($sessionInactivityTimeout = $this->getSessionInactivityTimeout()) {
259
            $sessionConfiguration[ServletSessionInterface::SESSION_INACTIVITY_TIMEOUT] = (string) $sessionInactivityTimeout;
260
        }
261
        if ($sessionFilePrefix = $this->getSessionFilePrefix()) {
262
            $sessionConfiguration[ServletSessionInterface::SESSION_FILE_PREFIX] = (string) $sessionFilePrefix;
263
        }
264
        if ($sessionCookieSecure = $this->getSessionCookieSecure()) {
265
            $sessionConfiguration[ServletSessionInterface::SESSION_COOKIE_SECURE] = (string) $sessionCookieSecure;
266
        }
267
        if ($sessionCookiePath = $this->getSessionCookiePath()) {
268
            $sessionConfiguration[ServletSessionInterface::SESSION_COOKIE_PATH] = (string) $sessionCookiePath;
269
        }
270
        if ($sessionCookieLifetime = $this->getSessionCookieLifetime()) {
271
            $sessionConfiguration[ServletSessionInterface::SESSION_COOKIE_LIFETIME] = (string) $sessionCookieLifetime;
272
        }
273
        if ($sessionCookieHttpOnly = $this->getSessionCookieHttpOnly()) {
274
            $sessionConfiguration[ServletSessionInterface::SESSION_COOKIE_HTTP_ONLY] = (string) $sessionCookieHttpOnly;
275
        }
276
        if ($sessionCookieDomain = $this->getSessionCookieDomain()) {
277
            $sessionConfiguration[ServletSessionInterface::SESSION_COOKIE_DOMAIN] = (string) $sessionCookieDomain;
278
        }
279
        if ($garbageCollectionProbability = $this->getGarbageCollectionProbability()) {
280
            $sessionConfiguration[ServletSessionInterface::GARBAGE_COLLECTION_PROBABILITY] = (string) $garbageCollectionProbability;
281
        }
282
283
        // return the array with the session configuration
284
        return $sessionConfiguration;
285
    }
286
}
287