@@ -15,7 +15,7 @@ |
||
| 15 | 15 | private readonly string $controller, |
| 16 | 16 | int $options = 0, |
| 17 | 17 | string $defaultAction = 'index' |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | parent::__construct( |
| 20 | 20 | ['action' => null], |
| 21 | 21 | ['action' => null], |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | private readonly array $controllers, |
| 16 | 16 | int $options = 0, |
| 17 | 17 | string $defaultAction = 'index' |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | parent::__construct( |
| 20 | 20 | ['controller' => null, 'action' => null], |
| 21 | 21 | ['controller' => \array_keys($controllers), 'action' => null], |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct( |
| 25 | 25 | private readonly string $controller, |
| 26 | - private readonly string|array $action, |
|
| 26 | + private readonly string | array $action, |
|
| 27 | 27 | int $options = 0 |
| 28 | - ) { |
|
| 29 | - if (\is_string($action)) { |
|
| 28 | + ){ |
|
| 29 | + if (\is_string($action)){ |
|
| 30 | 30 | parent::__construct( |
| 31 | 31 | ['action' => $action], |
| 32 | 32 | ['action' => new Autofill($action)], |
| 33 | 33 | $options |
| 34 | 34 | ); |
| 35 | - } else { |
|
| 35 | + }else{ |
|
| 36 | 36 | parent::__construct( |
| 37 | 37 | ['action' => null], |
| 38 | 38 | ['action' => $action], |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | protected function resolveAction(array $matches): string |
| 50 | 50 | { |
| 51 | 51 | $action = $this->action; |
| 52 | - if (\is_string($action)) { |
|
| 52 | + if (\is_string($action)){ |
|
| 53 | 53 | return $action; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -26,13 +26,16 @@ discard block |
||
| 26 | 26 | private readonly string|array $action, |
| 27 | 27 | int $options = 0 |
| 28 | 28 | ) { |
| 29 | - if (\is_string($action)) { |
|
| 29 | + if (\is_string($action)) |
|
| 30 | + { |
|
| 30 | 31 | parent::__construct( |
| 31 | 32 | ['action' => $action], |
| 32 | 33 | ['action' => new Autofill($action)], |
| 33 | 34 | $options |
| 34 | 35 | ); |
| 35 | - } else { |
|
| 36 | + } |
|
| 37 | + else |
|
| 38 | + { |
|
| 36 | 39 | parent::__construct( |
| 37 | 40 | ['action' => null], |
| 38 | 41 | ['action' => $action], |
@@ -49,7 +52,8 @@ discard block |
||
| 49 | 52 | protected function resolveAction(array $matches): string |
| 50 | 53 | { |
| 51 | 54 | $action = $this->action; |
| 52 | - if (\is_string($action)) { |
|
| 55 | + if (\is_string($action)) |
|
| 56 | + { |
|
| 53 | 57 | return $action; |
| 54 | 58 | } |
| 55 | 59 | |
@@ -9,6 +9,6 @@ |
||
| 9 | 9 | public function __construct( |
| 10 | 10 | public readonly ?object $actor, |
| 11 | 11 | public readonly ?string $transport = null |
| 12 | - ) { |
|
| 12 | + ){ |
|
| 13 | 13 | } |
| 14 | 14 | } |
@@ -11,6 +11,6 @@ |
||
| 11 | 11 | public function __construct( |
| 12 | 12 | public readonly TokenInterface $token, |
| 13 | 13 | public readonly ?string $transport = null |
| 14 | - ) { |
|
| 14 | + ){ |
|
| 15 | 15 | } |
| 16 | 16 | } |
@@ -43,11 +43,13 @@ |
||
| 43 | 43 | |
| 44 | 44 | public function getActor(): ?object |
| 45 | 45 | { |
| 46 | - if ($this->closed) { |
|
| 46 | + if ($this->closed) |
|
| 47 | + { |
|
| 47 | 48 | return null; |
| 48 | 49 | } |
| 49 | 50 | |
| 50 | - if ($this->actor === null && $this->token !== null) { |
|
| 51 | + if ($this->actor === null && $this->token !== null) |
|
| 52 | + { |
|
| 51 | 53 | $this->actor = $this->actorProvider->getActor($this->token); |
| 52 | 54 | } |
| 53 | 55 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | public function __construct( |
| 19 | 19 | private readonly ActorProviderInterface $actorProvider, |
| 20 | 20 | private readonly ?EventDispatcherInterface $eventDispatcher = null |
| 21 | - ) { |
|
| 21 | + ){ |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function start(TokenInterface $token, ?string $transport = null): void |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public function getActor(): ?object |
| 45 | 45 | { |
| 46 | - if ($this->closed) { |
|
| 46 | + if ($this->closed){ |
|
| 47 | 47 | return null; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if ($this->actor === null && $this->token !== null) { |
|
| 50 | + if ($this->actor === null && $this->token !== null){ |
|
| 51 | 51 | $this->actor = $this->actorProvider->getActor($this->token); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | public function __construct( |
| 15 | 15 | private readonly ?string $domain = null, |
| 16 | 16 | private readonly bool $secure = false |
| 17 | - ) { |
|
| 17 | + ){ |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | bool $httpOnly = true, |
| 74 | 74 | ?string $sameSite = null |
| 75 | 75 | ): self { |
| 76 | - if (\is_null($domain)) { |
|
| 76 | + if (\is_null($domain)){ |
|
| 77 | 77 | //Let's resolve domain via config |
| 78 | 78 | $domain = $this->domain; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if (\is_null($secure)) { |
|
| 81 | + if (\is_null($secure)){ |
|
| 82 | 82 | $secure = $this->secure; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function delete(string $name): void |
| 104 | 104 | { |
| 105 | - foreach ($this->scheduled as $index => $cookie) { |
|
| 106 | - if ($cookie->getName() === $name) { |
|
| 105 | + foreach ($this->scheduled as $index => $cookie){ |
|
| 106 | + if ($cookie->getName() === $name){ |
|
| 107 | 107 | unset($this->scheduled[$index]); |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -73,12 +73,14 @@ discard block |
||
| 73 | 73 | bool $httpOnly = true, |
| 74 | 74 | ?string $sameSite = null |
| 75 | 75 | ): self { |
| 76 | - if (\is_null($domain)) { |
|
| 76 | + if (\is_null($domain)) |
|
| 77 | + { |
|
| 77 | 78 | //Let's resolve domain via config |
| 78 | 79 | $domain = $this->domain; |
| 79 | 80 | } |
| 80 | 81 | |
| 81 | - if (\is_null($secure)) { |
|
| 82 | + if (\is_null($secure)) |
|
| 83 | + { |
|
| 82 | 84 | $secure = $this->secure; |
| 83 | 85 | } |
| 84 | 86 | |
@@ -102,8 +104,10 @@ discard block |
||
| 102 | 104 | */ |
| 103 | 105 | public function delete(string $name): void |
| 104 | 106 | { |
| 105 | - foreach ($this->scheduled as $index => $cookie) { |
|
| 106 | - if ($cookie->getName() === $name) { |
|
| 107 | + foreach ($this->scheduled as $index => $cookie) |
|
| 108 | + { |
|
| 109 | + if ($cookie->getName() === $name) |
|
| 110 | + { |
|
| 107 | 111 | unset($this->scheduled[$index]); |
| 108 | 112 | } |
| 109 | 113 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | private readonly bool $secure = false, |
| 63 | 63 | private readonly bool $httpOnly = true, |
| 64 | 64 | ?string $sameSite = null |
| 65 | - ) { |
|
| 65 | + ){ |
|
| 66 | 66 | $this->sameSite = new Cookie\SameSite($sameSite, $secure); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -158,30 +158,30 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function createHeader(): string |
| 160 | 160 | { |
| 161 | - $header = [\rawurlencode($this->name) . '=' . \rawurlencode((string)$this->value)]; |
|
| 161 | + $header = [\rawurlencode($this->name).'='.\rawurlencode((string)$this->value)]; |
|
| 162 | 162 | |
| 163 | - if ($this->lifetime !== null) { |
|
| 164 | - $header[] = 'Expires=' . \gmdate(\DateTime::COOKIE, $this->getExpires()); |
|
| 163 | + if ($this->lifetime !== null){ |
|
| 164 | + $header[] = 'Expires='.\gmdate(\DateTime::COOKIE, $this->getExpires()); |
|
| 165 | 165 | $header[] = \sprintf('Max-Age=%d', $this->lifetime); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if (!empty($this->path)) { |
|
| 168 | + if (!empty($this->path)){ |
|
| 169 | 169 | $header[] = \sprintf('Path=%s', $this->path); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - if (!empty($this->domain)) { |
|
| 172 | + if (!empty($this->domain)){ |
|
| 173 | 173 | $header[] = \sprintf('Domain=%s', $this->domain); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ($this->secure) { |
|
| 176 | + if ($this->secure){ |
|
| 177 | 177 | $header[] = 'Secure'; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if ($this->httpOnly) { |
|
| 180 | + if ($this->httpOnly){ |
|
| 181 | 181 | $header[] = 'HttpOnly'; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ($this->sameSite->get() !== null) { |
|
| 184 | + if ($this->sameSite->get() !== null){ |
|
| 185 | 185 | $header[] = \sprintf('SameSite=%s', $this->sameSite->get()); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | public function getExpires(): ?int |
| 197 | 197 | { |
| 198 | - if ($this->lifetime === null) { |
|
| 198 | + if ($this->lifetime === null){ |
|
| 199 | 199 | return null; |
| 200 | 200 | } |
| 201 | 201 | |
@@ -160,28 +160,34 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | $header = [\rawurlencode($this->name) . '=' . \rawurlencode((string)$this->value)]; |
| 162 | 162 | |
| 163 | - if ($this->lifetime !== null) { |
|
| 163 | + if ($this->lifetime !== null) |
|
| 164 | + { |
|
| 164 | 165 | $header[] = 'Expires=' . \gmdate(\DateTime::COOKIE, $this->getExpires()); |
| 165 | 166 | $header[] = \sprintf('Max-Age=%d', $this->lifetime); |
| 166 | 167 | } |
| 167 | 168 | |
| 168 | - if (!empty($this->path)) { |
|
| 169 | + if (!empty($this->path)) |
|
| 170 | + { |
|
| 169 | 171 | $header[] = \sprintf('Path=%s', $this->path); |
| 170 | 172 | } |
| 171 | 173 | |
| 172 | - if (!empty($this->domain)) { |
|
| 174 | + if (!empty($this->domain)) |
|
| 175 | + { |
|
| 173 | 176 | $header[] = \sprintf('Domain=%s', $this->domain); |
| 174 | 177 | } |
| 175 | 178 | |
| 176 | - if ($this->secure) { |
|
| 179 | + if ($this->secure) |
|
| 180 | + { |
|
| 177 | 181 | $header[] = 'Secure'; |
| 178 | 182 | } |
| 179 | 183 | |
| 180 | - if ($this->httpOnly) { |
|
| 184 | + if ($this->httpOnly) |
|
| 185 | + { |
|
| 181 | 186 | $header[] = 'HttpOnly'; |
| 182 | 187 | } |
| 183 | 188 | |
| 184 | - if ($this->sameSite->get() !== null) { |
|
| 189 | + if ($this->sameSite->get() !== null) |
|
| 190 | + { |
|
| 185 | 191 | $header[] = \sprintf('SameSite=%s', $this->sameSite->get()); |
| 186 | 192 | } |
| 187 | 193 | |
@@ -195,7 +201,8 @@ discard block |
||
| 195 | 201 | */ |
| 196 | 202 | public function getExpires(): ?int |
| 197 | 203 | { |
| 198 | - if ($this->lifetime === null) { |
|
| 204 | + if ($this->lifetime === null) |
|
| 205 | + { |
|
| 199 | 206 | return null; |
| 200 | 207 | } |
| 201 | 208 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function __construct(array $topics = []) |
| 12 | 12 | { |
| 13 | - foreach ($topics as $topic => $callback) { |
|
| 13 | + foreach ($topics as $topic => $callback){ |
|
| 14 | 14 | $this->register($topic, $callback); |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public function findCallback(string $topic, array &$matches): ?callable |
| 24 | 24 | { |
| 25 | - foreach ($this->patterns as $pattern => $callback) { |
|
| 26 | - if (\preg_match($pattern, $topic, $matches)) { |
|
| 25 | + foreach ($this->patterns as $pattern => $callback){ |
|
| 26 | + if (\preg_match($pattern, $topic, $matches)){ |
|
| 27 | 27 | return $callback; |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | private function compilePattern(string $topic): string |
| 35 | 35 | { |
| 36 | 36 | $replaces = []; |
| 37 | - if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
| 37 | + if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)){ |
|
| 38 | 38 | $variables = \array_combine($matches[1], $matches[2]); |
| 39 | - foreach ($variables as $key => $_) { |
|
| 40 | - $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
|
| 39 | + foreach ($variables as $key => $_){ |
|
| 40 | + $replaces['{'.$key.'}'] = '(?P<'.$key.'>[^\/\.]+)'; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - return '/^' . \strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']) . '$/iu'; |
|
| 44 | + return '/^'.\strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']).'$/iu'; |
|
| 45 | 45 | } |
| 46 | 46 | } |
@@ -10,7 +10,8 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function __construct(array $topics = []) |
| 12 | 12 | { |
| 13 | - foreach ($topics as $topic => $callback) { |
|
| 13 | + foreach ($topics as $topic => $callback) |
|
| 14 | + { |
|
| 14 | 15 | $this->register($topic, $callback); |
| 15 | 16 | } |
| 16 | 17 | } |
@@ -22,8 +23,10 @@ discard block |
||
| 22 | 23 | |
| 23 | 24 | public function findCallback(string $topic, array &$matches): ?callable |
| 24 | 25 | { |
| 25 | - foreach ($this->patterns as $pattern => $callback) { |
|
| 26 | - if (\preg_match($pattern, $topic, $matches)) { |
|
| 26 | + foreach ($this->patterns as $pattern => $callback) |
|
| 27 | + { |
|
| 28 | + if (\preg_match($pattern, $topic, $matches)) |
|
| 29 | + { |
|
| 27 | 30 | return $callback; |
| 28 | 31 | } |
| 29 | 32 | } |
@@ -34,9 +37,11 @@ discard block |
||
| 34 | 37 | private function compilePattern(string $topic): string |
| 35 | 38 | { |
| 36 | 39 | $replaces = []; |
| 37 | - if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
| 40 | + if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) |
|
| 41 | + { |
|
| 38 | 42 | $variables = \array_combine($matches[1], $matches[2]); |
| 39 | - foreach ($variables as $key => $_) { |
|
| 43 | + foreach ($variables as $key => $_) |
|
| 44 | + { |
|
| 40 | 45 | $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
| 41 | 46 | } |
| 42 | 47 | } |