@@ -123,9 +123,9 @@ |
||
123 | 123 | */ |
124 | 124 | public function getActiveSession(): SessionInterface |
125 | 125 | { |
126 | - try { |
|
126 | + try{ |
|
127 | 127 | return $this->container->get(SessionInterface::class); |
128 | - } catch (NotFoundExceptionInterface $e) { |
|
128 | + }catch (NotFoundExceptionInterface $e){ |
|
129 | 129 | throw new ScopeException('Unable to receive active session, invalid request scope', $e->getCode(), $e); |
130 | 130 | } |
131 | 131 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | string $domain = null, |
119 | 119 | bool $secure = null, |
120 | 120 | bool $httpOnly = true |
121 | - ) { |
|
121 | + ){ |
|
122 | 122 | $this->getCookieQueue()->set($name, $value, $lifetime, $path, $domain, $secure, $httpOnly); |
123 | 123 | |
124 | 124 | return $this; |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | */ |
170 | 170 | private function getRequest(): ServerRequestInterface |
171 | 171 | { |
172 | - try { |
|
172 | + try{ |
|
173 | 173 | return $this->container->get(ServerRequestInterface::class); |
174 | - } catch (NotFoundExceptionInterface $e) { |
|
174 | + }catch (NotFoundExceptionInterface $e){ |
|
175 | 175 | throw new ScopeException('Unable to receive active request', $e->getCode(), $e); |
176 | 176 | } |
177 | 177 | } |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | */ |
184 | 184 | private function getCookieQueue(): CookieQueue |
185 | 185 | { |
186 | - try { |
|
186 | + try{ |
|
187 | 187 | return $this->container->get(CookieQueue::class); |
188 | - } catch (NotFoundExceptionInterface $e) { |
|
188 | + }catch (NotFoundExceptionInterface $e){ |
|
189 | 189 | throw new ScopeException('Unable to receive cookie queue, invalid request scope', $e->getCode(), $e); |
190 | 190 | } |
191 | 191 | } |
@@ -98,7 +98,7 @@ |
||
98 | 98 | public static function unpack(array $data): Token |
99 | 99 | { |
100 | 100 | $expiresAt = null; |
101 | - if ($data['expiredAt'] != null) { |
|
101 | + if ($data['expiredAt'] != null){ |
|
102 | 102 | $expiresAt = (new \DateTimeImmutable())->setTimestamp($data['expiredAt']); |
103 | 103 | } |
104 | 104 |
@@ -46,7 +46,7 @@ |
||
46 | 46 | array $payload, |
47 | 47 | \DateTimeImmutable $createdAt, |
48 | 48 | \DateTimeInterface $expiresAt = null |
49 | - ) { |
|
49 | + ){ |
|
50 | 50 | $this->hash = $hash; |
51 | 51 | $this->createdAt = $createdAt; |
52 | 52 | $this->expiresAt = $expiresAt; |
@@ -94,9 +94,9 @@ |
||
94 | 94 | */ |
95 | 95 | private function getAuthContext(): AuthContextInterface |
96 | 96 | { |
97 | - try { |
|
97 | + try{ |
|
98 | 98 | return $this->container->get(AuthContextInterface::class); |
99 | - } catch (NotFoundExceptionInterface $e) { |
|
99 | + }catch (NotFoundExceptionInterface $e){ |
|
100 | 100 | throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); |
101 | 101 | } |
102 | 102 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | PermissionsInterface $permissions, |
42 | 42 | ContainerInterface $actorScope, |
43 | 43 | array $roles = [] |
44 | - ) { |
|
44 | + ){ |
|
45 | 45 | $this->roles = $roles; |
46 | 46 | $this->container = $actorScope; |
47 | 47 | $this->permissions = $permissions; |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | public function allows(string $permission, array $context = []): bool |
56 | 56 | { |
57 | 57 | $allows = false; |
58 | - foreach ($this->getRoles() as $role) { |
|
59 | - if (!$this->permissions->hasRole($role)) { |
|
58 | + foreach ($this->getRoles() as $role){ |
|
59 | + if (!$this->permissions->hasRole($role)){ |
|
60 | 60 | continue; |
61 | 61 | } |
62 | 62 | |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getActor(): ActorInterface |
105 | 105 | { |
106 | - if (!is_null($this->actor)) { |
|
106 | + if (!is_null($this->actor)){ |
|
107 | 107 | return $this->actor; |
108 | 108 | } |
109 | 109 | |
110 | - try { |
|
110 | + try{ |
|
111 | 111 | return $this->container->get(ActorInterface::class); |
112 | - } catch (NotFoundExceptionInterface $e) { |
|
112 | + }catch (NotFoundExceptionInterface $e){ |
|
113 | 113 | throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e); |
114 | 114 | } |
115 | 115 | } |
@@ -41,25 +41,25 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function load(string $id): ?TokenInterface |
43 | 43 | { |
44 | - if (strpos($id, ':') === false) { |
|
44 | + if (strpos($id, ':') === false){ |
|
45 | 45 | return null; |
46 | 46 | } |
47 | 47 | |
48 | 48 | list($pk, $hash) = explode(':', $id, 2); |
49 | 49 | |
50 | - if (!is_numeric($id)) { |
|
50 | + if (!is_numeric($id)){ |
|
51 | 51 | return null; |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** @var TokenInterface $token */ |
55 | 55 | $token = $this->findByPK((int)$pk); |
56 | 56 | |
57 | - if ($token === null || $token->getID() !== $id) { |
|
57 | + if ($token === null || $token->getID() !== $id){ |
|
58 | 58 | // hijacked or deleted |
59 | 59 | return null; |
60 | 60 | } |
61 | 61 | |
62 | - if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) { |
|
62 | + if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()){ |
|
63 | 63 | $this->delete($token); |
64 | 64 | return null; |
65 | 65 | } |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
74 | 74 | { |
75 | - try { |
|
75 | + try{ |
|
76 | 76 | $token = new Token($this->randomHash(128), $payload, new \DateTimeImmutable(), $expiresAt); |
77 | 77 | |
78 | 78 | (new Transaction($this->orm))->persist($token)->run(); |
79 | 79 | |
80 | 80 | return $token; |
81 | - } catch (\Throwable $e) { |
|
81 | + }catch (\Throwable $e){ |
|
82 | 82 | throw new TokenStorageException('Unable to create token', $e->getCode(), $e); |
83 | 83 | } |
84 | 84 | } |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function delete(TokenInterface $token): void |
90 | 90 | { |
91 | - try { |
|
91 | + try{ |
|
92 | 92 | (new Transaction($this->orm))->delete($token)->run(); |
93 | - } catch (\Throwable $e) { |
|
93 | + }catch (\Throwable $e){ |
|
94 | 94 | throw new TokenStorageException('Unable to delete token', $e->getCode(), $e); |
95 | 95 | } |
96 | 96 | } |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | public function getTransports(): array |
41 | 41 | { |
42 | 42 | $transports = []; |
43 | - foreach ($this->config['transports'] as $transport) { |
|
44 | - if (is_object($transport) && !$transport instanceof Autowire) { |
|
43 | + foreach ($this->config['transports'] as $transport){ |
|
44 | + if (is_object($transport) && !$transport instanceof Autowire){ |
|
45 | 45 | $transports[] = $transport; |
46 | 46 | continue; |
47 | 47 | } |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | */ |
61 | 61 | private function wire($item): Autowire |
62 | 62 | { |
63 | - if ($item instanceof Autowire) { |
|
63 | + if ($item instanceof Autowire){ |
|
64 | 64 | return $item; |
65 | 65 | } |
66 | 66 | |
67 | - if (is_string($item)) { |
|
67 | + if (is_string($item)){ |
|
68 | 68 | return new Autowire($item); |
69 | 69 | } |
70 | 70 | |
71 | - if (is_array($item) && isset($item['class'])) { |
|
71 | + if (is_array($item) && isset($item['class'])){ |
|
72 | 72 | return new Autowire($item['class'], $item['options'] ?? []); |
73 | 73 | } |
74 | 74 |
@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function load(string $id): ?TokenInterface |
45 | 45 | { |
46 | - try { |
|
46 | + try{ |
|
47 | 47 | $tokenData = $this->getAuthSection()->get('token'); |
48 | 48 | $token = Token::unpack($tokenData); |
49 | - } catch (\Throwable $e) { |
|
49 | + }catch (\Throwable $e){ |
|
50 | 50 | throw new TokenStorageException('Unable to load session token', $e->getCode(), $e); |
51 | 51 | } |
52 | 52 | |
53 | - if ($token->getID() !== $id) { |
|
53 | + if ($token->getID() !== $id){ |
|
54 | 54 | return null; |
55 | 55 | } |
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,12 +67,12 @@ 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($this->randomHash(123), $payload, $expiresAt); |
72 | 72 | $this->getAuthSection()->set('token', $token->pack()); |
73 | 73 | |
74 | 74 | return $token; |
75 | - } catch (\Throwable $e) { |
|
75 | + }catch (\Throwable $e){ |
|
76 | 76 | throw new TokenStorageException('Unable to create session token', $e->getCode(), $e); |
77 | 77 | } |
78 | 78 | } |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | */ |
91 | 91 | private function getAuthSection(): SessionSectionInterface |
92 | 92 | { |
93 | - try { |
|
93 | + try{ |
|
94 | 94 | $session = $this->container->get(SessionInterface::class); |
95 | 95 | |
96 | 96 | /** @var SessionInterface $session */ |
97 | 97 | return $session->getSection(self::SESSION_SECTION); |
98 | - } catch (ContainerExceptionInterface $e) { |
|
98 | + }catch (ContainerExceptionInterface $e){ |
|
99 | 99 | throw new ScopeException('Unable to find auth token, invalid session scope', $e->getCode(), $e); |
100 | 100 | } |
101 | 101 | } |