@@ -40,18 +40,18 @@ 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 | 45 | $token = Token::unpack($tokenData); |
46 | - } catch (\Throwable $e) { |
|
46 | + }catch (\Throwable $e){ |
|
47 | 47 | throw new TokenStorageException('Unable to load session token', $e->getCode(), $e); |
48 | 48 | } |
49 | 49 | |
50 | - if ($token->getID() !== $id) { |
|
50 | + if ($token->getID() !== $id){ |
|
51 | 51 | return null; |
52 | 52 | } |
53 | 53 | |
54 | - if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) { |
|
54 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()){ |
|
55 | 55 | $this->delete($token); |
56 | 56 | return null; |
57 | 57 | } |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
66 | 66 | { |
67 | - try { |
|
67 | + try{ |
|
68 | 68 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
69 | 69 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
70 | 70 | |
71 | 71 | return $token; |
72 | - } catch (\Throwable $e) { |
|
72 | + }catch (\Throwable $e){ |
|
73 | 73 | throw new TokenStorageException('Unable to create session token', $e->getCode(), $e); |
74 | 74 | } |
75 | 75 | } |
@@ -40,18 +40,23 @@ 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 | 46 | $token = Token::unpack($tokenData); |
46 | - } catch (\Throwable $e) { |
|
47 | + } |
|
48 | + catch (\Throwable $e) |
|
49 | + { |
|
47 | 50 | throw new TokenStorageException('Unable to load session token', $e->getCode(), $e); |
48 | 51 | } |
49 | 52 | |
50 | - if ($token->getID() !== $id) { |
|
53 | + if ($token->getID() !== $id) |
|
54 | + { |
|
51 | 55 | return null; |
52 | 56 | } |
53 | 57 | |
54 | - if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) { |
|
58 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() > new \DateTime()) |
|
59 | + { |
|
55 | 60 | $this->delete($token); |
56 | 61 | return null; |
57 | 62 | } |
@@ -64,12 +69,15 @@ discard block |
||
64 | 69 | */ |
65 | 70 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
66 | 71 | { |
67 | - try { |
|
72 | + try |
|
73 | + { |
|
68 | 74 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
69 | 75 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
70 | 76 | |
71 | 77 | return $token; |
72 | - } catch (\Throwable $e) { |
|
78 | + } |
|
79 | + catch (\Throwable $e) |
|
80 | + { |
|
73 | 81 | throw new TokenStorageException('Unable to create session token', $e->getCode(), $e); |
74 | 82 | } |
75 | 83 | } |