@@ -40,8 +40,10 @@ |
||
40 | 40 | * @Guarded("do") |
41 | 41 | * @return string |
42 | 42 | */ |
43 | - public function do() |
|
43 | + public function do{ |
|
44 | + () |
|
44 | 45 | { |
45 | 46 | return 'ok'; |
46 | 47 | } |
48 | + } |
|
47 | 49 | } |
@@ -40,22 +40,22 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function load(string $id): ?TokenInterface |
42 | 42 | { |
43 | - try { |
|
43 | + try{ |
|
44 | 44 | $tokenData = $this->session->getSection(self::SESSION_SECTION)->get('token'); |
45 | - if ($tokenData === null) { |
|
45 | + if ($tokenData === null){ |
|
46 | 46 | return null; |
47 | 47 | } |
48 | 48 | |
49 | 49 | $token = Token::unpack($tokenData); |
50 | - } catch (\Throwable $e) { |
|
50 | + }catch (\Throwable $e){ |
|
51 | 51 | throw new TokenStorageException('Unable to load session token', $e->getCode(), $e); |
52 | 52 | } |
53 | 53 | |
54 | - if (!hash_equals($token->getID(), $id)) { |
|
54 | + if (!hash_equals($token->getID(), $id)){ |
|
55 | 55 | return null; |
56 | 56 | } |
57 | 57 | |
58 | - if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) { |
|
58 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()){ |
|
59 | 59 | $this->delete($token); |
60 | 60 | return null; |
61 | 61 | } |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
70 | 70 | { |
71 | - try { |
|
71 | + try{ |
|
72 | 72 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
73 | 73 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
74 | 74 | |
75 | 75 | return $token; |
76 | - } catch (\Throwable $e) { |
|
76 | + }catch (\Throwable $e){ |
|
77 | 77 | throw new TokenStorageException('Unable to create session token', $e->getCode(), $e); |
78 | 78 | } |
79 | 79 | } |
@@ -40,22 +40,28 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function load(string $id): ?TokenInterface |
42 | 42 | { |
43 | - try { |
|
43 | + try |
|
44 | + { |
|
44 | 45 | $tokenData = $this->session->getSection(self::SESSION_SECTION)->get('token'); |
45 | - if ($tokenData === null) { |
|
46 | + if ($tokenData === null) |
|
47 | + { |
|
46 | 48 | return null; |
47 | 49 | } |
48 | 50 | |
49 | 51 | $token = Token::unpack($tokenData); |
50 | - } catch (\Throwable $e) { |
|
52 | + } |
|
53 | + catch (\Throwable $e) |
|
54 | + { |
|
51 | 55 | throw new TokenStorageException('Unable to load session token', $e->getCode(), $e); |
52 | 56 | } |
53 | 57 | |
54 | - if (!hash_equals($token->getID(), $id)) { |
|
58 | + if (!hash_equals($token->getID(), $id)) |
|
59 | + { |
|
55 | 60 | return null; |
56 | 61 | } |
57 | 62 | |
58 | - if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) { |
|
63 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) |
|
64 | + { |
|
59 | 65 | $this->delete($token); |
60 | 66 | return null; |
61 | 67 | } |
@@ -68,12 +74,15 @@ discard block |
||
68 | 74 | */ |
69 | 75 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
70 | 76 | { |
71 | - try { |
|
77 | + try |
|
78 | + { |
|
72 | 79 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
73 | 80 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
74 | 81 | |
75 | 82 | return $token; |
76 | - } catch (\Throwable $e) { |
|
83 | + } |
|
84 | + catch (\Throwable $e) |
|
85 | + { |
|
77 | 86 | throw new TokenStorageException('Unable to create session token', $e->getCode(), $e); |
78 | 87 | } |
79 | 88 | } |