Completed
Push — master ( cb434b...b50652 )
by Felipe
04:13
created
src/Contracts/PSR7SessionInterface.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
  */
11 11
 interface PSR7SessionInterface
12 12
 {
13
-	/**
14
-	 * @param array $decoded_data
15
-	 * @return string
16
-	 */
17
-	public function encoder(array $decoded_data): string;
13
+    /**
14
+     * @param array $decoded_data
15
+     * @return string
16
+     */
17
+    public function encoder(array $decoded_data): string;
18 18
 
19
-	/**
20
-	 * @param string $encoded_data
21
-	 * @return array
22
-	 */
23
-	public function decoder(string $encoded_data): array;
19
+    /**
20
+     * @param string $encoded_data
21
+     * @return array
22
+     */
23
+    public function decoder(string $encoded_data): array;
24 24
 }
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
src/PSR7Session.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -10,49 +10,49 @@
 block discarded – undo
10 10
  */
11 11
 final class PSR7Session implements Contracts\PSR7SessionInterface
12 12
 {
13
-	/**
14
-	 * {@inheritDoc}
15
-	 */
16
-	public function encoder(array $decodedData): string
17
-	{
18
-		$encodedData = '';
19
-
20
-		if (!empty($decodedData)) {
21
-			foreach ($decodedData as $key => $value) {
22
-				$encodedData .= $key . '|' . serialize($value);
23
-			}
24
-		}
25
-
26
-		return $encodedData;
27
-	}
28
-
29
-	/**
30
-	 * {@inheritDoc}
31
-	 * @throws \SessionEncoderDecoder\Exceptions\InvalidFormatException
32
-	 */
33
-	public function decoder(string $encodedData): array
34
-	{
35
-		$decodedData = [];
36
-
37
-		if (!($encodedData === '')) {
38
-			$offset = 0;
39
-
40
-			while ($offset < strlen($encodedData)) {
41
-				if (!strstr(substr($encodedData, $offset), "|")) {
42
-					throw new Exceptions\InvalidFormatException(substr($encodedData, $offset));
43
-				}
44
-
45
-				$num = strpos($encodedData, "|", $offset) - $offset;
46
-				$key = substr($encodedData, $offset, $num);
47
-				$offset += $num + 1;
48
-
49
-				$data = unserialize(substr($encodedData, $offset));
50
-				$offset += strlen(serialize($data));
51
-
52
-				$decodedData[$key] = $data;
53
-			}
54
-		}
55
-
56
-		return $decodedData;
57
-	}
13
+    /**
14
+     * {@inheritDoc}
15
+     */
16
+    public function encoder(array $decodedData): string
17
+    {
18
+        $encodedData = '';
19
+
20
+        if (!empty($decodedData)) {
21
+            foreach ($decodedData as $key => $value) {
22
+                $encodedData .= $key . '|' . serialize($value);
23
+            }
24
+        }
25
+
26
+        return $encodedData;
27
+    }
28
+
29
+    /**
30
+     * {@inheritDoc}
31
+     * @throws \SessionEncoderDecoder\Exceptions\InvalidFormatException
32
+     */
33
+    public function decoder(string $encodedData): array
34
+    {
35
+        $decodedData = [];
36
+
37
+        if (!($encodedData === '')) {
38
+            $offset = 0;
39
+
40
+            while ($offset < strlen($encodedData)) {
41
+                if (!strstr(substr($encodedData, $offset), "|")) {
42
+                    throw new Exceptions\InvalidFormatException(substr($encodedData, $offset));
43
+                }
44
+
45
+                $num = strpos($encodedData, "|", $offset) - $offset;
46
+                $key = substr($encodedData, $offset, $num);
47
+                $offset += $num + 1;
48
+
49
+                $data = unserialize(substr($encodedData, $offset));
50
+                $offset += strlen(serialize($data));
51
+
52
+                $decodedData[$key] = $data;
53
+            }
54
+        }
55
+
56
+        return $decodedData;
57
+    }
58 58
 }
59 59
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
 		if (!empty($decodedData)) {
21 21
 			foreach ($decodedData as $key => $value) {
22
-				$encodedData .= $key . '|' . serialize($value);
22
+				$encodedData .= $key.'|'.serialize($value);
23 23
 			}
24 24
 		}
25 25
 
Please login to merge, or discard this patch.
src/Exceptions/InvalidFormatException.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
  */
14 14
 class InvalidFormatException extends Exception
15 15
 {
16
-	public function __construct(string $message = '', int $code = 0, Throwable $previous = null)
17
-	{
18
-		parent::__construct('Invalid data, remaining: '.$message, $code, $previous);
19
-	}
16
+    public function __construct(string $message = '', int $code = 0, Throwable $previous = null)
17
+    {
18
+        parent::__construct('Invalid data, remaining: '.$message, $code, $previous);
19
+    }
20 20
 }
21 21
\ No newline at end of file
Please login to merge, or discard this patch.