Passed
Push — master ( 3fc8df...c1f4b8 )
by smiley
01:23
created
src/SessionHandlerException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,4 +12,4 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Session;
14 14
 
15
-class SessionHandlerException extends \Exception{}
15
+class SessionHandlerException extends \Exception {}
Please login to merge, or discard this patch.
src/DBSessionHandler.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@
 block discarded – undo
82 82
 			}
83 83
 
84 84
 			return $this->options->use_encryption ? $this->decrypt($q[0]->data) : $q[0]->data;
85
-		}
86
-		catch(\Exception $e){
85
+		} catch(\Exception $e){
87 86
 			throw new SessionHandlerException($e->getMessage());
88 87
 		}
89 88
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use chillerlan\Settings\SettingsContainerInterface;
17 17
 use Psr\Log\LoggerInterface;
18 18
 
19
-class DBSessionHandler extends SessionHandlerAbstract{
19
+class DBSessionHandler extends SessionHandlerAbstract {
20 20
 
21 21
 	/**
22 22
 	 * @var \chillerlan\Database\Database
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @param \chillerlan\Settings\SettingsContainerInterface $options
31 31
 	 * @param \Psr\Log\LoggerInterface|null                  $logger
32 32
 	 */
33
-	public function __construct(Database $db, SettingsContainerInterface $options = null, LoggerInterface $logger = null){
33
+	public function __construct(Database $db, SettingsContainerInterface $options = null, LoggerInterface $logger = null) {
34 34
 		parent::__construct($options, $logger);
35 35
 
36 36
 		$this->db = $db->connect();
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function read($session_id):string{
78 78
 
79
-		if(empty($session_id)){
79
+		if (empty($session_id)) {
80 80
 			throw new SessionHandlerException('invalid session id');
81 81
 		}
82 82
 
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 			->where('id', $session_id)
87 87
 			->query();
88 88
 
89
-		try{
89
+		try {
90 90
 
91
-			if(!$q || !isset($q[0])){
91
+			if (!$q || !isset($q[0])) {
92 92
 				return '';
93 93
 			}
94 94
 
95 95
 			return $this->options->use_encryption ? $this->decrypt($q[0]->data) : $q[0]->data;
96 96
 		}
97
-		catch(\Exception $e){
97
+		catch (\Exception $e) {
98 98
 			throw new SessionHandlerException($e->getMessage());
99 99
 		}
100 100
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function write($session_id, $session_data):bool{
108 108
 
109
-		if(empty($session_id)){
109
+		if (empty($session_id)) {
110 110
 			throw new SessionHandlerException('invalid session id');
111 111
 		}
112 112
 
Please login to merge, or discard this patch.
src/SessionHandlerOptionsTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\Session;
14 14
 
15
-trait SessionHandlerOptionsTrait{
15
+trait SessionHandlerOptionsTrait {
16 16
 
17 17
 	protected $filename_prefix = 'SESSION_';
18 18
 	protected $session_name    = 'SESSIONID';
Please login to merge, or discard this patch.
public/database.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 	'password' => $env->get('DB_PASSWORD'),
32 32
 ];
33 33
 
34
-$options = new class($options) extends \chillerlan\Settings\SettingsContainerAbstract{
34
+$options = new class($options) extends \chillerlan\Settings\SettingsContainerAbstract {
35 35
 	use DatabaseOptionsTrait, SessionHandlerOptionsTrait;
36 36
 };
37 37
 
Please login to merge, or discard this patch.
src/SessionInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 use SessionHandlerInterface;
16 16
 
17
-interface SessionInterface extends SessionHandlerInterface{
17
+interface SessionInterface extends SessionHandlerInterface {
18 18
 
19 19
 	const SESSION_NONCE = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02";
20 20
 
Please login to merge, or discard this patch.
src/SessionHandlerOptions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,6 +26,6 @@
 block discarded – undo
26 26
  * @property bool   $use_encryption
27 27
  * @property string $sessionCryptoKey
28 28
  */
29
-class SessionHandlerOptions extends SettingsContainerAbstract{
29
+class SessionHandlerOptions extends SettingsContainerAbstract {
30 30
 	use SessionHandlerOptionsTrait;
31 31
 }
Please login to merge, or discard this patch.
src/SessionHandlerAbstract.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param \chillerlan\Settings\SettingsContainerInterface $options
36 36
 	 * @param \Psr\Log\LoggerInterface|null                  $logger
37 37
 	 */
38
-	public function __construct(SettingsContainerInterface $options = null, LoggerInterface $logger = null){
38
+	public function __construct(SettingsContainerInterface $options = null, LoggerInterface $logger = null) {
39 39
 		$this->options = $options ?? new SessionHandlerOptions;
40 40
 		$this->logger  = $logger ?? new NullLogger;
41 41
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function start():SessionInterface{
52 52
 
53
-		if($this->active()){
53
+		if ($this->active()) {
54 54
 			throw new SessionHandlerException('session already running');
55 55
 		}
56 56
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	/** @inheritdoc */
74 74
 	public function end():SessionInterface{
75 75
 
76
-		if($this->active()){
76
+		if ($this->active()) {
77 77
 			\session_regenerate_id(true);
78 78
 			\setcookie(\session_name(), '', 0, $this->options->cookie_path);
79 79
 			\session_unset();
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	}
91 91
 
92 92
 	/** @inheritdoc */
93
-	public function get(string $name){
93
+	public function get(string $name) {
94 94
 		return $_SESSION[$name] ?? null;
95 95
 	}
96 96
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function encrypt(string &$data):string {
128 128
 
129
-		if(\function_exists('sodium_crypto_secretbox')){
129
+		if (\function_exists('sodium_crypto_secretbox')) {
130 130
 			$box = \sodium_crypto_secretbox($data, $this::SESSION_NONCE, \sodium_hex2bin($this->options->sessionCryptoKey));
131 131
 
132 132
 			\sodium_memzero($data);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	protected function decrypt(string $box):string {
147 147
 
148
-		if(\function_exists('sodium_crypto_secretbox_open')){
148
+		if (\function_exists('sodium_crypto_secretbox_open')) {
149 149
 			return \sodium_crypto_secretbox_open(\sodium_hex2bin($box), $this::SESSION_NONCE, \sodium_hex2bin($this->options->sessionCryptoKey));
150 150
 		}
151 151
 
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	public function setOptions(SettingsContainerInterface $options):SessionInterface{
161 161
 
162 162
 		// end an active session before setting new options
163
-		if($this->active()){
163
+		if ($this->active()) {
164 164
 			$this->end();
165 165
 		}
166 166
 
167
-		if(\is_writable($options->save_path)){
167
+		if (\is_writable($options->save_path)) {
168 168
 			\ini_set('session.save_path', $options->save_path);
169 169
 		}
170 170
 
Please login to merge, or discard this patch.