@@ -50,7 +50,7 @@ |
||
50 | 50 | array $payload, |
51 | 51 | \DateTimeImmutable $createdAt, |
52 | 52 | \DateTimeInterface $expiresAt = null |
53 | - ) { |
|
53 | + ){ |
|
54 | 54 | $this->id = $id; |
55 | 55 | |
56 | 56 | $this->secretValue = $secretValue; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function load(string $id): ?TokenInterface |
40 | 40 | { |
41 | - if (strpos($id, ':') === false) { |
|
41 | + if (strpos($id, ':') === false){ |
|
42 | 42 | return null; |
43 | 43 | } |
44 | 44 | |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | /** @var Token $token */ |
48 | 48 | $token = $this->orm->getRepository(Token::class)->findByPK($pk); |
49 | 49 | |
50 | - if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))) { |
|
50 | + if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))){ |
|
51 | 51 | // hijacked or deleted |
52 | 52 | return null; |
53 | 53 | } |
54 | 54 | |
55 | 55 | $token->setSecretValue($hash); |
56 | 56 | |
57 | - if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) { |
|
57 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()){ |
|
58 | 58 | $this->delete($token); |
59 | 59 | return null; |
60 | 60 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
69 | 69 | { |
70 | - try { |
|
70 | + try{ |
|
71 | 71 | $token = new Token( |
72 | 72 | $this->issueID(), |
73 | 73 | $this->randomHash(128), |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | (new Transaction($this->orm))->persist($token)->run(); |
80 | 80 | |
81 | 81 | return $token; |
82 | - } catch (\Throwable $e) { |
|
82 | + }catch (\Throwable $e){ |
|
83 | 83 | throw new TokenStorageException('Unable to create token', $e->getCode(), $e); |
84 | 84 | } |
85 | 85 | } |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function delete(TokenInterface $token): void |
91 | 91 | { |
92 | - try { |
|
92 | + try{ |
|
93 | 93 | (new Transaction($this->orm))->delete($token)->run(); |
94 | - } catch (\Throwable $e) { |
|
94 | + }catch (\Throwable $e){ |
|
95 | 95 | throw new TokenStorageException('Unable to delete token', $e->getCode(), $e); |
96 | 96 | } |
97 | 97 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $this->orm->getSource(Token::class)->getTable() |
111 | 111 | ); |
112 | 112 | |
113 | - while ((clone $query)->where('id', $id)->count('id') !== 0) { |
|
113 | + while ((clone $query)->where('id', $id)->count('id') !== 0){ |
|
114 | 114 | $id = $this->randomHash(64); |
115 | 115 | } |
116 | 116 |
@@ -38,7 +38,8 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function load(string $id): ?TokenInterface |
40 | 40 | { |
41 | - if (strpos($id, ':') === false) { |
|
41 | + if (strpos($id, ':') === false) |
|
42 | + { |
|
42 | 43 | return null; |
43 | 44 | } |
44 | 45 | |
@@ -47,14 +48,16 @@ discard block |
||
47 | 48 | /** @var Token $token */ |
48 | 49 | $token = $this->orm->getRepository(Token::class)->findByPK($pk); |
49 | 50 | |
50 | - if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))) { |
|
51 | + if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))) |
|
52 | + { |
|
51 | 53 | // hijacked or deleted |
52 | 54 | return null; |
53 | 55 | } |
54 | 56 | |
55 | 57 | $token->setSecretValue($hash); |
56 | 58 | |
57 | - if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) { |
|
59 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) |
|
60 | + { |
|
58 | 61 | $this->delete($token); |
59 | 62 | return null; |
60 | 63 | } |
@@ -67,7 +70,8 @@ discard block |
||
67 | 70 | */ |
68 | 71 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
69 | 72 | { |
70 | - try { |
|
73 | + try |
|
74 | + { |
|
71 | 75 | $token = new Token( |
72 | 76 | $this->issueID(), |
73 | 77 | $this->randomHash(128), |
@@ -79,7 +83,9 @@ discard block |
||
79 | 83 | (new Transaction($this->orm))->persist($token)->run(); |
80 | 84 | |
81 | 85 | return $token; |
82 | - } catch (\Throwable $e) { |
|
86 | + } |
|
87 | + catch (\Throwable $e) |
|
88 | + { |
|
83 | 89 | throw new TokenStorageException('Unable to create token', $e->getCode(), $e); |
84 | 90 | } |
85 | 91 | } |
@@ -89,9 +95,12 @@ discard block |
||
89 | 95 | */ |
90 | 96 | public function delete(TokenInterface $token): void |
91 | 97 | { |
92 | - try { |
|
98 | + try |
|
99 | + { |
|
93 | 100 | (new Transaction($this->orm))->delete($token)->run(); |
94 | - } catch (\Throwable $e) { |
|
101 | + } |
|
102 | + catch (\Throwable $e) |
|
103 | + { |
|
95 | 104 | throw new TokenStorageException('Unable to delete token', $e->getCode(), $e); |
96 | 105 | } |
97 | 106 | } |
@@ -110,7 +119,8 @@ discard block |
||
110 | 119 | $this->orm->getSource(Token::class)->getTable() |
111 | 120 | ); |
112 | 121 | |
113 | - while ((clone $query)->where('id', $id)->count('id') !== 0) { |
|
122 | + while ((clone $query)->where('id', $id)->count('id') !== 0) |
|
123 | + { |
|
114 | 124 | $id = $this->randomHash(64); |
115 | 125 | } |
116 | 126 |