@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | private readonly CookiesConfig $cookiesConfig, |
35 | 35 | private readonly SessionFactoryInterface $factory, |
36 | 36 | private readonly ScopeInterface $scope, |
37 | - ) {} |
|
37 | + ){} |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @throws \Throwable |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | $this->fetchID($request), |
48 | 48 | ); |
49 | 49 | |
50 | - try { |
|
50 | + try{ |
|
51 | 51 | $response = $handler->handle($request->withAttribute(self::ATTRIBUTE, $session)); |
52 | - } catch (\Throwable $e) { |
|
52 | + }catch (\Throwable $e){ |
|
53 | 53 | $session->abort(); |
54 | 54 | throw $e; |
55 | 55 | } |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | Request $request, |
63 | 63 | Response $response, |
64 | 64 | ): Response { |
65 | - if (!$session->isStarted()) { |
|
65 | + if (!$session->isStarted()){ |
|
66 | 66 | return $response; |
67 | 67 | } |
68 | 68 | |
69 | 69 | $session->commit(); |
70 | 70 | |
71 | 71 | //SID changed |
72 | - if ($this->fetchID($request) !== $session->getID()) { |
|
72 | + if ($this->fetchID($request) !== $session->getID()){ |
|
73 | 73 | return $this->withCookie($request, $response, $session->getID()); |
74 | 74 | } |
75 | 75 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | protected function fetchID(Request $request): ?string |
84 | 84 | { |
85 | 85 | $cookies = $request->getCookieParams(); |
86 | - if (empty($cookies[$this->config->getCookie()])) { |
|
86 | + if (empty($cookies[$this->config->getCookie()])){ |
|
87 | 87 | return null; |
88 | 88 | } |
89 | 89 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | protected function clientSignature(Request $request): string |
106 | 106 | { |
107 | 107 | $signature = ''; |
108 | - foreach (self::SIGNATURE_HEADERS as $header) { |
|
109 | - $signature .= $request->getHeaderLine($header) . ';'; |
|
108 | + foreach (self::SIGNATURE_HEADERS as $header){ |
|
109 | + $signature .= $request->getHeaderLine($header).';'; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | return \hash('sha256', $signature); |
@@ -34,7 +34,8 @@ discard block |
||
34 | 34 | private readonly CookiesConfig $cookiesConfig, |
35 | 35 | private readonly SessionFactoryInterface $factory, |
36 | 36 | private readonly ScopeInterface $scope, |
37 | - ) {} |
|
37 | + ) { |
|
38 | +} |
|
38 | 39 | |
39 | 40 | /** |
40 | 41 | * @throws \Throwable |
@@ -47,9 +48,12 @@ discard block |
||
47 | 48 | $this->fetchID($request), |
48 | 49 | ); |
49 | 50 | |
50 | - try { |
|
51 | + try |
|
52 | + { |
|
51 | 53 | $response = $handler->handle($request->withAttribute(self::ATTRIBUTE, $session)); |
52 | - } catch (\Throwable $e) { |
|
54 | + } |
|
55 | + catch (\Throwable $e) |
|
56 | + { |
|
53 | 57 | $session->abort(); |
54 | 58 | throw $e; |
55 | 59 | } |
@@ -62,14 +66,16 @@ discard block |
||
62 | 66 | Request $request, |
63 | 67 | Response $response, |
64 | 68 | ): Response { |
65 | - if (!$session->isStarted()) { |
|
69 | + if (!$session->isStarted()) |
|
70 | + { |
|
66 | 71 | return $response; |
67 | 72 | } |
68 | 73 | |
69 | 74 | $session->commit(); |
70 | 75 | |
71 | 76 | //SID changed |
72 | - if ($this->fetchID($request) !== $session->getID()) { |
|
77 | + if ($this->fetchID($request) !== $session->getID()) |
|
78 | + { |
|
73 | 79 | return $this->withCookie($request, $response, $session->getID()); |
74 | 80 | } |
75 | 81 | |
@@ -83,7 +89,8 @@ discard block |
||
83 | 89 | protected function fetchID(Request $request): ?string |
84 | 90 | { |
85 | 91 | $cookies = $request->getCookieParams(); |
86 | - if (empty($cookies[$this->config->getCookie()])) { |
|
92 | + if (empty($cookies[$this->config->getCookie()])) |
|
93 | + { |
|
87 | 94 | return null; |
88 | 95 | } |
89 | 96 | |
@@ -105,7 +112,8 @@ discard block |
||
105 | 112 | protected function clientSignature(Request $request): string |
106 | 113 | { |
107 | 114 | $signature = ''; |
108 | - foreach (self::SIGNATURE_HEADERS as $header) { |
|
115 | + foreach (self::SIGNATURE_HEADERS as $header) |
|
116 | + { |
|
109 | 117 | $signature .= $request->getHeaderLine($header) . ';'; |
110 | 118 | } |
111 | 119 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct( |
24 | 24 | #[Proxy] private readonly ContainerInterface $container, |
25 | - ) {} |
|
25 | + ){} |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @throws ScopeException |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getActiveSession(): SessionInterface |
97 | 97 | { |
98 | - try { |
|
98 | + try{ |
|
99 | 99 | return $this->container->get(SessionInterface::class); |
100 | - } catch (NotFoundExceptionInterface $e) { |
|
100 | + }catch (NotFoundExceptionInterface $e){ |
|
101 | 101 | throw new ScopeException( |
102 | 102 | 'Unable to receive active session, invalid request scope', |
103 | 103 | $e->getCode(), |
@@ -22,7 +22,8 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct( |
24 | 24 | #[Proxy] private readonly ContainerInterface $container, |
25 | - ) {} |
|
25 | + ) { |
|
26 | +} |
|
26 | 27 | |
27 | 28 | /** |
28 | 29 | * @throws ScopeException |
@@ -95,9 +96,12 @@ discard block |
||
95 | 96 | */ |
96 | 97 | public function getActiveSession(): SessionInterface |
97 | 98 | { |
98 | - try { |
|
99 | + try |
|
100 | + { |
|
99 | 101 | return $this->container->get(SessionInterface::class); |
100 | - } catch (NotFoundExceptionInterface $e) { |
|
102 | + } |
|
103 | + catch (NotFoundExceptionInterface $e) |
|
104 | + { |
|
101 | 105 | throw new ScopeException( |
102 | 106 | 'Unable to receive active session, invalid request scope', |
103 | 107 | $e->getCode(), |
@@ -12,7 +12,7 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | private readonly SessionScope $session, |
14 | 14 | private readonly string $name, |
15 | - ) {} |
|
15 | + ){} |
|
16 | 16 | |
17 | 17 | public function getIterator(): \Traversable |
18 | 18 | { |
@@ -12,7 +12,8 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | private readonly SessionScope $session, |
14 | 14 | private readonly string $name, |
15 | - ) {} |
|
15 | + ) { |
|
16 | +} |
|
16 | 17 | |
17 | 18 | public function getIterator(): \Traversable |
18 | 19 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | string $filename, |
26 | 26 | string $destination, |
27 | 27 | string $mergeMode = self::FOLLOW, |
28 | - int $mode = FilesInterface::READONLY, |
|
28 | + int $mode = FilesInterface::readonly, |
|
29 | 29 | ): void; |
30 | 30 | |
31 | 31 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | string $directory, |
38 | 38 | string $destination, |
39 | 39 | string $mergeMode = self::REPLACE, |
40 | - int $mode = FilesInterface::READONLY, |
|
40 | + int $mode = FilesInterface::readonly, |
|
41 | 41 | ): void; |
42 | 42 | |
43 | 43 | /** |
@@ -45,5 +45,5 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @throws PublishException |
47 | 47 | */ |
48 | - public function ensureDirectory(string $directory, int $mode = FilesInterface::READONLY): void; |
|
48 | + public function ensureDirectory(string $directory, int $mode = FilesInterface::readonly): void; |
|
49 | 49 | } |
@@ -4,4 +4,4 @@ |
||
4 | 4 | |
5 | 5 | namespace Spiral\Module\Exception; |
6 | 6 | |
7 | -class PublishException extends \RuntimeException {} |
|
7 | +class PublishException extends \RuntimeException{} |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | { |
16 | 16 | public function __construct( |
17 | 17 | private readonly FilesInterface $files, |
18 | - ) {} |
|
18 | + ){} |
|
19 | 19 | |
20 | 20 | public function publish( |
21 | 21 | string $filename, |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | string $mergeMode = self::FOLLOW, |
24 | 24 | int $mode = FilesInterface::READONLY, |
25 | 25 | ): void { |
26 | - if (!$this->files->isFile($filename)) { |
|
26 | + if (!$this->files->isFile($filename)){ |
|
27 | 27 | throw new PublishException(\sprintf("Given '%s' is not valid file", $filename)); |
28 | 28 | } |
29 | 29 | |
30 | - if ($this->files->exists($destination)) { |
|
31 | - if ($this->files->md5($destination) === $this->files->md5($filename)) { |
|
30 | + if ($this->files->exists($destination)){ |
|
31 | + if ($this->files->md5($destination) === $this->files->md5($filename)){ |
|
32 | 32 | //Nothing to do |
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | - if ($mergeMode === self::FOLLOW) { |
|
36 | + if ($mergeMode === self::FOLLOW){ |
|
37 | 37 | return; |
38 | 38 | } |
39 | 39 | } |
@@ -52,17 +52,17 @@ discard block |
||
52 | 52 | string $mergeMode = self::REPLACE, |
53 | 53 | int $mode = FilesInterface::READONLY, |
54 | 54 | ): void { |
55 | - if (!$this->files->isDirectory($directory)) { |
|
55 | + if (!$this->files->isDirectory($directory)){ |
|
56 | 56 | throw new PublishException(\sprintf("Given '%s' is not valid directory", $directory)); |
57 | 57 | } |
58 | 58 | |
59 | 59 | $finder = new Finder(); |
60 | 60 | $finder->files()->in($directory); |
61 | 61 | |
62 | - foreach ($finder->getIterator() as $file) { |
|
62 | + foreach ($finder->getIterator() as $file){ |
|
63 | 63 | $this->publish( |
64 | - (string) $file, |
|
65 | - $destination . '/' . $file->getRelativePathname(), |
|
64 | + (string)$file, |
|
65 | + $destination.'/'.$file->getRelativePathname(), |
|
66 | 66 | $mergeMode, |
67 | 67 | $mode, |
68 | 68 | ); |
@@ -15,7 +15,8 @@ discard block |
||
15 | 15 | { |
16 | 16 | public function __construct( |
17 | 17 | private readonly FilesInterface $files, |
18 | - ) {} |
|
18 | + ) { |
|
19 | +} |
|
19 | 20 | |
20 | 21 | public function publish( |
21 | 22 | string $filename, |
@@ -23,17 +24,21 @@ discard block |
||
23 | 24 | string $mergeMode = self::FOLLOW, |
24 | 25 | int $mode = FilesInterface::READONLY, |
25 | 26 | ): void { |
26 | - if (!$this->files->isFile($filename)) { |
|
27 | + if (!$this->files->isFile($filename)) |
|
28 | + { |
|
27 | 29 | throw new PublishException(\sprintf("Given '%s' is not valid file", $filename)); |
28 | 30 | } |
29 | 31 | |
30 | - if ($this->files->exists($destination)) { |
|
31 | - if ($this->files->md5($destination) === $this->files->md5($filename)) { |
|
32 | + if ($this->files->exists($destination)) |
|
33 | + { |
|
34 | + if ($this->files->md5($destination) === $this->files->md5($filename)) |
|
35 | + { |
|
32 | 36 | //Nothing to do |
33 | 37 | return; |
34 | 38 | } |
35 | 39 | |
36 | - if ($mergeMode === self::FOLLOW) { |
|
40 | + if ($mergeMode === self::FOLLOW) |
|
41 | + { |
|
37 | 42 | return; |
38 | 43 | } |
39 | 44 | } |
@@ -52,14 +57,16 @@ discard block |
||
52 | 57 | string $mergeMode = self::REPLACE, |
53 | 58 | int $mode = FilesInterface::READONLY, |
54 | 59 | ): void { |
55 | - if (!$this->files->isDirectory($directory)) { |
|
60 | + if (!$this->files->isDirectory($directory)) |
|
61 | + { |
|
56 | 62 | throw new PublishException(\sprintf("Given '%s' is not valid directory", $directory)); |
57 | 63 | } |
58 | 64 | |
59 | 65 | $finder = new Finder(); |
60 | 66 | $finder->files()->in($directory); |
61 | 67 | |
62 | - foreach ($finder->getIterator() as $file) { |
|
68 | + foreach ($finder->getIterator() as $file) |
|
69 | + { |
|
63 | 70 | $this->publish( |
64 | 71 | (string) $file, |
65 | 72 | $destination . '/' . $file->getRelativePathname(), |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | string $filename, |
22 | 22 | string $destination, |
23 | 23 | string $mergeMode = self::FOLLOW, |
24 | - int $mode = FilesInterface::READONLY, |
|
24 | + int $mode = FilesInterface::readonly, |
|
25 | 25 | ): void { |
26 | 26 | if (!$this->files->isFile($filename)) { |
27 | 27 | throw new PublishException(\sprintf("Given '%s' is not valid file", $filename)); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | string $directory, |
51 | 51 | string $destination, |
52 | 52 | string $mergeMode = self::REPLACE, |
53 | - int $mode = FilesInterface::READONLY, |
|
53 | + int $mode = FilesInterface::readonly, |
|
54 | 54 | ): void { |
55 | 55 | if (!$this->files->isDirectory($directory)) { |
56 | 56 | throw new PublishException(\sprintf("Given '%s' is not valid directory", $directory)); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - public function ensureDirectory(string $directory, int $mode = FilesInterface::READONLY): void |
|
72 | + public function ensureDirectory(string $directory, int $mode = FilesInterface::readonly): void |
|
73 | 73 | { |
74 | 74 | $this->files->ensureDirectory($directory, $mode); |
75 | 75 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private readonly StorageSnapshot $storageSnapshot, |
11 | - ) {} |
|
11 | + ){} |
|
12 | 12 | |
13 | 13 | public function register(\Throwable $e): SnapshotInterface |
14 | 14 | { |
@@ -8,7 +8,8 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private readonly StorageSnapshot $storageSnapshot, |
11 | - ) {} |
|
11 | + ) { |
|
12 | +} |
|
12 | 13 | |
13 | 14 | public function register(\Throwable $e): SnapshotInterface |
14 | 15 | { |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private readonly FileSnapshot $fileSnapshot, |
11 | - ) {} |
|
11 | + ){} |
|
12 | 12 | |
13 | 13 | public function register(\Throwable $e): SnapshotInterface |
14 | 14 | { |
@@ -8,7 +8,8 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private readonly FileSnapshot $fileSnapshot, |
11 | - ) {} |
|
11 | + ) { |
|
12 | +} |
|
12 | 13 | |
13 | 14 | public function register(\Throwable $e): SnapshotInterface |
14 | 15 | { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | public function __construct( |
24 | 24 | #[Proxy] private readonly ContainerInterface $container, |
25 | - ) {} |
|
25 | + ){} |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @throws ScopeException |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | */ |
150 | 150 | private function getRequest(): ServerRequestInterface |
151 | 151 | { |
152 | - try { |
|
152 | + try{ |
|
153 | 153 | return $this->container->get(ServerRequestInterface::class); |
154 | - } catch (NotFoundExceptionInterface $e) { |
|
154 | + }catch (NotFoundExceptionInterface $e){ |
|
155 | 155 | throw new ScopeException('Unable to receive active request', $e->getCode(), $e); |
156 | 156 | } |
157 | 157 | } |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private function getCookieQueue(): CookieQueue |
163 | 163 | { |
164 | - try { |
|
164 | + try{ |
|
165 | 165 | return $this->container->get(CookieQueue::class); |
166 | - } catch (NotFoundExceptionInterface $e) { |
|
166 | + }catch (NotFoundExceptionInterface $e){ |
|
167 | 167 | throw new ScopeException('Unable to receive cookie queue, invalid request scope', $e->getCode(), $e); |
168 | 168 | } |
169 | 169 | } |
@@ -22,7 +22,8 @@ discard block |
||
22 | 22 | { |
23 | 23 | public function __construct( |
24 | 24 | #[Proxy] private readonly ContainerInterface $container, |
25 | - ) {} |
|
25 | + ) { |
|
26 | +} |
|
26 | 27 | |
27 | 28 | /** |
28 | 29 | * @throws ScopeException |
@@ -149,9 +150,12 @@ discard block |
||
149 | 150 | */ |
150 | 151 | private function getRequest(): ServerRequestInterface |
151 | 152 | { |
152 | - try { |
|
153 | + try |
|
154 | + { |
|
153 | 155 | return $this->container->get(ServerRequestInterface::class); |
154 | - } catch (NotFoundExceptionInterface $e) { |
|
156 | + } |
|
157 | + catch (NotFoundExceptionInterface $e) |
|
158 | + { |
|
155 | 159 | throw new ScopeException('Unable to receive active request', $e->getCode(), $e); |
156 | 160 | } |
157 | 161 | } |
@@ -161,9 +165,12 @@ discard block |
||
161 | 165 | */ |
162 | 166 | private function getCookieQueue(): CookieQueue |
163 | 167 | { |
164 | - try { |
|
168 | + try |
|
169 | + { |
|
165 | 170 | return $this->container->get(CookieQueue::class); |
166 | - } catch (NotFoundExceptionInterface $e) { |
|
171 | + } |
|
172 | + catch (NotFoundExceptionInterface $e) |
|
173 | + { |
|
167 | 174 | throw new ScopeException('Unable to receive cookie queue, invalid request scope', $e->getCode(), $e); |
168 | 175 | } |
169 | 176 | } |