]> git.mxchange.org Git - friendica.git/blob - src/Core/Session/ISession.php
Merge branch 'develop' of https://github.com/friendica/friendica into develop
[friendica.git] / src / Core / Session / ISession.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2021, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Core\Session;
23
24 /**
25  * Contains all global supported Session methods
26  */
27 interface ISession
28 {
29         /**
30          * Start the current session
31          *
32          * @return self The own Session instance
33          */
34         public function start();
35
36         /**
37          * Checks if the key exists in this session
38          *
39          * @param string $name
40          *
41          * @return boolean True, if it exists
42          */
43         public function exists(string $name);
44
45         /**
46          * Retrieves a key from the session super global or the defaults if the key is missing or the value is falsy.
47          *
48          * Handle the case where session_start() hasn't been called and the super global isn't available.
49          *
50          * @param string $name
51          * @param mixed  $defaults
52          *
53          * @return mixed
54          */
55         public function get(string $name, $defaults = null);
56
57         /**
58          * Sets a single session variable.
59          * Overrides value of existing key.
60          *
61          * @param string $name
62          * @param mixed  $value
63          */
64         public function set(string $name, $value);
65
66         /**
67          * Sets multiple session variables.
68          * Overrides values for existing keys.
69          *
70          * @param array $values
71          */
72         public function setMultiple(array $values);
73
74         /**
75          * Removes a session variable.
76          * Ignores missing keys.
77          *
78          * @param string $name
79          */
80         public function remove(string $name);
81
82         /**
83          * Clears the current session array
84          */
85         public function clear();
86 }