@@ -14,16 +14,16 @@ discard block |
||
14 | 14 | |
15 | 15 | public function __construct( |
16 | 16 | private readonly DateTimeFactoryInterface $factory = new DateTimeFactory(), |
17 | - ) {} |
|
17 | + ){} |
|
18 | 18 | |
19 | 19 | public function create(mixed $duration): \DateInterval |
20 | 20 | { |
21 | - try { |
|
21 | + try{ |
|
22 | 22 | return $this->createOrFail($duration); |
23 | - } catch (\InvalidArgumentException $e) { |
|
23 | + }catch (\InvalidArgumentException $e){ |
|
24 | 24 | throw $e; |
25 | - } catch (\Throwable $e) { |
|
26 | - throw new \InvalidArgumentException($e->getMessage(), (int) $e->getCode(), $e); |
|
25 | + }catch (\Throwable $e){ |
|
26 | + throw new \InvalidArgumentException($e->getMessage(), (int)$e->getCode(), $e); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $duration instanceof \DateInterval => $duration, |
44 | 44 | $duration instanceof \DateTimeInterface => $this->factory->now()->diff($duration), |
45 | 45 | \is_string($duration) => new \DateInterval($duration), |
46 | - \is_int($duration) => new \DateInterval('PT' . $duration . 'S'), |
|
46 | + \is_int($duration) => new \DateInterval('PT'.$duration.'S'), |
|
47 | 47 | $duration === null => new \DateInterval('PT0S'), |
48 | 48 | default => throw new \InvalidArgumentException( |
49 | 49 | \sprintf(self::ERROR_INVALID_INTERVAL_TYPE, \get_debug_type($duration)), |
@@ -14,15 +14,21 @@ |
||
14 | 14 | |
15 | 15 | public function __construct( |
16 | 16 | private readonly DateTimeFactoryInterface $factory = new DateTimeFactory(), |
17 | - ) {} |
|
17 | + ) { |
|
18 | +} |
|
18 | 19 | |
19 | 20 | public function create(mixed $duration): \DateInterval |
20 | 21 | { |
21 | - try { |
|
22 | + try |
|
23 | + { |
|
22 | 24 | return $this->createOrFail($duration); |
23 | - } catch (\InvalidArgumentException $e) { |
|
25 | + } |
|
26 | + catch (\InvalidArgumentException $e) |
|
27 | + { |
|
24 | 28 | throw $e; |
25 | - } catch (\Throwable $e) { |
|
29 | + } |
|
30 | + catch (\Throwable $e) |
|
31 | + { |
|
26 | 32 | throw new \InvalidArgumentException($e->getMessage(), (int) $e->getCode(), $e); |
27 | 33 | } |
28 | 34 | } |
@@ -43,6 +43,6 @@ |
||
43 | 43 | $prefix = \trim($this->host->getPath(), self::URI_PATH_DELIMITER); |
44 | 44 | $file = \trim($file, self::URI_PATH_DELIMITER); |
45 | 45 | |
46 | - return self::URI_PATH_DELIMITER . ($prefix === '' ? '' : $prefix . self::URI_PATH_DELIMITER) . $file; |
|
46 | + return self::URI_PATH_DELIMITER.($prefix === '' ? '' : $prefix.self::URI_PATH_DELIMITER).$file; |
|
47 | 47 | } |
48 | 48 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | private readonly S3ClientInterface $client, |
20 | 20 | private readonly string $bucket, |
21 | 21 | private readonly ?string $prefix = null, |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | parent::__construct(); |
24 | 24 | } |
25 | 25 |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | public function __construct( |
24 | 24 | private readonly ContainerInterface $container, |
25 | 25 | private readonly FactoryInterface $factory, |
26 | - ) {} |
|
26 | + ){} |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @throws ScopeException When no request are available. |
30 | 30 | */ |
31 | 31 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
32 | 32 | { |
33 | - if (!$this->container->has(ServerRequestInterface::class)) { |
|
33 | + if (!$this->container->has(ServerRequestInterface::class)){ |
|
34 | 34 | throw new ScopeException('Unable to create paginator, no request scope found'); |
35 | 35 | } |
36 | 36 | /** |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | //Getting page number |
42 | 42 | $page = 0; |
43 | - if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) { |
|
44 | - $page = (int) $query[$parameter]; |
|
43 | + if (!empty($query[$parameter]) && \is_scalar($query[$parameter])){ |
|
44 | + $page = (int)$query[$parameter]; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | return $this->factory->make(Paginator::class, ['limit' => $limit, 'parameter' => $parameter])->withPage($page); |
@@ -23,14 +23,16 @@ discard block |
||
23 | 23 | public function __construct( |
24 | 24 | private readonly ContainerInterface $container, |
25 | 25 | private readonly FactoryInterface $factory, |
26 | - ) {} |
|
26 | + ) { |
|
27 | +} |
|
27 | 28 | |
28 | 29 | /** |
29 | 30 | * @throws ScopeException When no request are available. |
30 | 31 | */ |
31 | 32 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
32 | 33 | { |
33 | - if (!$this->container->has(ServerRequestInterface::class)) { |
|
34 | + if (!$this->container->has(ServerRequestInterface::class)) |
|
35 | + { |
|
34 | 36 | throw new ScopeException('Unable to create paginator, no request scope found'); |
35 | 37 | } |
36 | 38 | /** |
@@ -40,7 +42,8 @@ discard block |
||
40 | 42 | |
41 | 43 | //Getting page number |
42 | 44 | $page = 0; |
43 | - if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) { |
|
45 | + if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) |
|
46 | + { |
|
44 | 47 | $page = (int) $query[$parameter]; |
45 | 48 | } |
46 | 49 |
@@ -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{} |