Completed
Push — master ( 8c6f59...89dfde )
by smiley
02:58
created
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/DBSessionHandler.php 1 patch
Spacing   +5 added lines, -5 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();
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 			->where('id', $session_id)
83 83
 			->query();
84 84
 
85
-		try{
85
+		try {
86 86
 
87
-			if(!$q || !isset($q[0])){
87
+			if (!$q || !isset($q[0])) {
88 88
 				return '';
89 89
 			}
90 90
 
91 91
 			return $this->options->use_encryption ? $this->decrypt($q[0]->data) : $q[0]->data;
92 92
 		}
93
-		catch(\Exception $e){
93
+		catch (\Exception $e) {
94 94
 			throw new SessionHandlerException($e->getMessage());
95 95
 		}
96 96
 
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   +7 added lines, -7 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
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		setcookie(
55 55
 			session_name(),
56 56
 			session_id(),
57
-			time()+$this->options->cookie_lifetime,
57
+			time() + $this->options->cookie_lifetime,
58 58
 			$this->options->cookie_path,
59 59
 			$cookie_params['domain']
60 60
 		);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	}
80 80
 
81 81
 	/** @inheritdoc */
82
-	public function get(string $name){
82
+	public function get(string $name) {
83 83
 		return $_SESSION[$name] ?? null;
84 84
 	}
85 85
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	protected function encrypt(string &$data):string {
112 112
 
113
-		if(function_exists('sodium_crypto_secretbox')){
113
+		if (function_exists('sodium_crypto_secretbox')) {
114 114
 			$box = sodium_crypto_secretbox($data, $this::SESSION_NONCE, sodium_hex2bin($this->options->sessionCryptoKey));
115 115
 
116 116
 			sodium_memzero($data);
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	protected function decrypt(string $box):string {
131 131
 
132
-		if(function_exists('sodium_crypto_secretbox_open')){
132
+		if (function_exists('sodium_crypto_secretbox_open')) {
133 133
 			return sodium_crypto_secretbox_open(sodium_hex2bin($box), $this::SESSION_NONCE, sodium_hex2bin($this->options->sessionCryptoKey));
134 134
 		}
135 135
 
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 	public function setOptions(SettingsContainerInterface $options):SessionInterface{
145 145
 
146 146
 		// end an active session before setting new options
147
-		if($this->active()){
147
+		if ($this->active()) {
148 148
 			$this->end();
149 149
 		}
150 150
 
151
-		if(is_writable($options->save_path)){
151
+		if (is_writable($options->save_path)) {
152 152
 			ini_set('session.save_path', $options->save_path);
153 153
 		}
154 154
 
Please login to merge, or discard this patch.