@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | ?FilesInterface $files = null, |
| 26 | 26 | private readonly string $defaultNamespace = self::DEFAULT_NAMESPACE, |
| 27 | 27 | private readonly ?EventDispatcherInterface $dispatcher = null, |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | $this->files = $files ?? new Files(); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function getExtension(): ?string |
| 41 | 41 | { |
| 42 | - if ($this->parser !== null) { |
|
| 42 | + if ($this->parser !== null){ |
|
| 43 | 43 | return $this->parser->getExtension(); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -50,24 +50,24 @@ discard block |
||
| 50 | 50 | * @psalm-assert-if-true non-empty-string $filename |
| 51 | 51 | * @psalm-assert-if-true ViewPath $parsed |
| 52 | 52 | */ |
| 53 | - public function exists(string $path, ?string &$filename = null, ?ViewPath &$parsed = null): bool |
|
| 53 | + public function exists(string $path, ?string &$filename = null, ?ViewPath & $parsed = null): bool |
|
| 54 | 54 | { |
| 55 | - if (empty($this->parser)) { |
|
| 55 | + if (empty($this->parser)){ |
|
| 56 | 56 | throw new LoaderException('Unable to locate view source, no extension has been associated.'); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $parsed = $this->parser->parse($path); |
| 60 | - if ($parsed === null) { |
|
| 60 | + if ($parsed === null){ |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if (!isset($this->namespaces[$parsed->getNamespace()])) { |
|
| 64 | + if (!isset($this->namespaces[$parsed->getNamespace()])){ |
|
| 65 | 65 | return false; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - foreach ((array)$this->namespaces[$parsed->getNamespace()] as $directory) { |
|
| 68 | + foreach ((array)$this->namespaces[$parsed->getNamespace()] as $directory){ |
|
| 69 | 69 | $directory = $this->files->normalizePath($directory, true); |
| 70 | - if ($this->files->exists(\sprintf('%s%s', $directory, $parsed->getBasename()))) { |
|
| 70 | + if ($this->files->exists(\sprintf('%s%s', $directory, $parsed->getBasename()))){ |
|
| 71 | 71 | $filename = \sprintf('%s%s', $directory, $parsed->getBasename()); |
| 72 | 72 | |
| 73 | 73 | return true; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function load(string $path): ViewSource |
| 81 | 81 | { |
| 82 | - if (!$this->exists($path, $filename, $parsed)) { |
|
| 82 | + if (!$this->exists($path, $filename, $parsed)){ |
|
| 83 | 83 | $this->dispatcher?->dispatch(new ViewNotFound($path)); |
| 84 | 84 | |
| 85 | 85 | throw new LoaderException(\sprintf('Unable to load view `%s`, file does not exist.', $path)); |
@@ -92,23 +92,23 @@ discard block |
||
| 92 | 92 | ); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function list(?string $namespace = null): array |
|
| 95 | + public function list(?string $namespace = null) : array |
|
| 96 | 96 | { |
| 97 | - if (empty($this->parser)) { |
|
| 97 | + if (empty($this->parser)){ |
|
| 98 | 98 | throw new LoaderException('Unable to list view sources, no extension has been associated.'); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $result = []; |
| 102 | - foreach ($this->namespaces as $ns => $directories) { |
|
| 103 | - if (!empty($namespace) && $namespace != $ns) { |
|
| 102 | + foreach ($this->namespaces as $ns => $directories){ |
|
| 103 | + if (!empty($namespace) && $namespace != $ns){ |
|
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - foreach ((array)$directories as $directory) { |
|
| 107 | + foreach ((array)$directories as $directory){ |
|
| 108 | 108 | $files = $this->files->getFiles($directory); |
| 109 | 109 | |
| 110 | - foreach ($files as $filename) { |
|
| 111 | - if (!$this->parser->match($filename)) { |
|
| 110 | + foreach ($files as $filename){ |
|
| 111 | + if (!$this->parser->match($filename)){ |
|
| 112 | 112 | // does not belong to this loader |
| 113 | 113 | continue; |
| 114 | 114 | } |
@@ -39,7 +39,8 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function getExtension(): ?string |
| 41 | 41 | { |
| 42 | - if ($this->parser !== null) { |
|
| 42 | + if ($this->parser !== null) |
|
| 43 | + { |
|
| 43 | 44 | return $this->parser->getExtension(); |
| 44 | 45 | } |
| 45 | 46 | |
@@ -52,22 +53,27 @@ discard block |
||
| 52 | 53 | */ |
| 53 | 54 | public function exists(string $path, ?string &$filename = null, ?ViewPath &$parsed = null): bool |
| 54 | 55 | { |
| 55 | - if (empty($this->parser)) { |
|
| 56 | + if (empty($this->parser)) |
|
| 57 | + { |
|
| 56 | 58 | throw new LoaderException('Unable to locate view source, no extension has been associated.'); |
| 57 | 59 | } |
| 58 | 60 | |
| 59 | 61 | $parsed = $this->parser->parse($path); |
| 60 | - if ($parsed === null) { |
|
| 62 | + if ($parsed === null) |
|
| 63 | + { |
|
| 61 | 64 | return false; |
| 62 | 65 | } |
| 63 | 66 | |
| 64 | - if (!isset($this->namespaces[$parsed->getNamespace()])) { |
|
| 67 | + if (!isset($this->namespaces[$parsed->getNamespace()])) |
|
| 68 | + { |
|
| 65 | 69 | return false; |
| 66 | 70 | } |
| 67 | 71 | |
| 68 | - foreach ((array)$this->namespaces[$parsed->getNamespace()] as $directory) { |
|
| 72 | + foreach ((array)$this->namespaces[$parsed->getNamespace()] as $directory) |
|
| 73 | + { |
|
| 69 | 74 | $directory = $this->files->normalizePath($directory, true); |
| 70 | - if ($this->files->exists(\sprintf('%s%s', $directory, $parsed->getBasename()))) { |
|
| 75 | + if ($this->files->exists(\sprintf('%s%s', $directory, $parsed->getBasename()))) |
|
| 76 | + { |
|
| 71 | 77 | $filename = \sprintf('%s%s', $directory, $parsed->getBasename()); |
| 72 | 78 | |
| 73 | 79 | return true; |
@@ -79,7 +85,8 @@ discard block |
||
| 79 | 85 | |
| 80 | 86 | public function load(string $path): ViewSource |
| 81 | 87 | { |
| 82 | - if (!$this->exists($path, $filename, $parsed)) { |
|
| 88 | + if (!$this->exists($path, $filename, $parsed)) |
|
| 89 | + { |
|
| 83 | 90 | $this->dispatcher?->dispatch(new ViewNotFound($path)); |
| 84 | 91 | |
| 85 | 92 | throw new LoaderException(\sprintf('Unable to load view `%s`, file does not exist.', $path)); |
@@ -94,21 +101,27 @@ discard block |
||
| 94 | 101 | |
| 95 | 102 | public function list(?string $namespace = null): array |
| 96 | 103 | { |
| 97 | - if (empty($this->parser)) { |
|
| 104 | + if (empty($this->parser)) |
|
| 105 | + { |
|
| 98 | 106 | throw new LoaderException('Unable to list view sources, no extension has been associated.'); |
| 99 | 107 | } |
| 100 | 108 | |
| 101 | 109 | $result = []; |
| 102 | - foreach ($this->namespaces as $ns => $directories) { |
|
| 103 | - if (!empty($namespace) && $namespace != $ns) { |
|
| 110 | + foreach ($this->namespaces as $ns => $directories) |
|
| 111 | + { |
|
| 112 | + if (!empty($namespace) && $namespace != $ns) |
|
| 113 | + { |
|
| 104 | 114 | continue; |
| 105 | 115 | } |
| 106 | 116 | |
| 107 | - foreach ((array)$directories as $directory) { |
|
| 117 | + foreach ((array)$directories as $directory) |
|
| 118 | + { |
|
| 108 | 119 | $files = $this->files->getFiles($directory); |
| 109 | 120 | |
| 110 | - foreach ($files as $filename) { |
|
| 111 | - if (!$this->parser->match($filename)) { |
|
| 121 | + foreach ($files as $filename) |
|
| 122 | + { |
|
| 123 | + if (!$this->parser->match($filename)) |
|
| 124 | + { |
|
| 112 | 125 | // does not belong to this loader |
| 113 | 126 | continue; |
| 114 | 127 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function reset(?ContextInterface $context = null): void |
| 14 | 14 | { |
| 15 | - if (empty($context)) { |
|
| 15 | + if (empty($context)){ |
|
| 16 | 16 | $this->cache = []; |
| 17 | 17 | return; |
| 18 | 18 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function resetPath(string $path): void |
| 27 | 27 | { |
| 28 | - foreach ($this->cache as &$cache) { |
|
| 28 | + foreach ($this->cache as &$cache){ |
|
| 29 | 29 | unset($cache[$path], $cache); |
| 30 | 30 | } |
| 31 | 31 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function get(ContextInterface $context, string $path): ViewInterface |
| 47 | 47 | { |
| 48 | - if (!$this->has($context, $path)) { |
|
| 48 | + if (!$this->has($context, $path)){ |
|
| 49 | 49 | throw new CacheException(\sprintf('No cache is available for %s.', $path)); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -12,7 +12,8 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function reset(?ContextInterface $context = null): void |
| 14 | 14 | { |
| 15 | - if (empty($context)) { |
|
| 15 | + if (empty($context)) |
|
| 16 | + { |
|
| 16 | 17 | $this->cache = []; |
| 17 | 18 | return; |
| 18 | 19 | } |
@@ -25,7 +26,8 @@ discard block |
||
| 25 | 26 | */ |
| 26 | 27 | public function resetPath(string $path): void |
| 27 | 28 | { |
| 28 | - foreach ($this->cache as &$cache) { |
|
| 29 | + foreach ($this->cache as &$cache) |
|
| 30 | + { |
|
| 29 | 31 | unset($cache[$path], $cache); |
| 30 | 32 | } |
| 31 | 33 | } |
@@ -45,7 +47,8 @@ discard block |
||
| 45 | 47 | */ |
| 46 | 48 | public function get(ContextInterface $context, string $path): ViewInterface |
| 47 | 49 | { |
| 48 | - if (!$this->has($context, $path)) { |
|
| 50 | + if (!$this->has($context, $path)) |
|
| 51 | + { |
|
| 49 | 52 | throw new CacheException(\sprintf('No cache is available for %s.', $path)); |
| 50 | 53 | } |
| 51 | 54 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | private readonly string $name, |
| 18 | 18 | private readonly mixed $value, |
| 19 | 19 | ?array $variants = null |
| 20 | - ) { |
|
| 20 | + ){ |
|
| 21 | 21 | $this->variants = $variants ?? [$value]; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -22,21 +22,21 @@ |
||
| 22 | 22 | public function __construct( |
| 23 | 23 | private readonly SessionConfig $config, |
| 24 | 24 | private readonly FactoryInterface $factory |
| 25 | - ) { |
|
| 25 | + ){ |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function initSession(string $clientSignature, ?string $id = null): SessionInterface |
| 29 | 29 | { |
| 30 | - if (\session_status() === PHP_SESSION_ACTIVE) { |
|
| 30 | + if (\session_status() === PHP_SESSION_ACTIVE){ |
|
| 31 | 31 | throw new MultipleSessionException('Unable to initiate session, session already started'); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // Initiating proper session handler |
| 35 | - if ($this->config->getHandler() !== null) { |
|
| 36 | - try { |
|
| 35 | + if ($this->config->getHandler() !== null){ |
|
| 36 | + try{ |
|
| 37 | 37 | $handler = $this->config->getHandler()->resolve($this->factory); |
| 38 | - } catch (\Throwable | ContainerExceptionInterface $e) { |
|
| 39 | - throw new SessionException($e->getMessage(), (int) $e->getCode(), $e); |
|
| 38 | + }catch (\Throwable | ContainerExceptionInterface $e){ |
|
| 39 | + throw new SessionException($e->getMessage(), (int)$e->getCode(), $e); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | \session_set_save_handler($handler, true); |
@@ -27,15 +27,20 @@ |
||
| 27 | 27 | |
| 28 | 28 | public function initSession(string $clientSignature, ?string $id = null): SessionInterface |
| 29 | 29 | { |
| 30 | - if (\session_status() === PHP_SESSION_ACTIVE) { |
|
| 30 | + if (\session_status() === PHP_SESSION_ACTIVE) |
|
| 31 | + { |
|
| 31 | 32 | throw new MultipleSessionException('Unable to initiate session, session already started'); |
| 32 | 33 | } |
| 33 | 34 | |
| 34 | 35 | // Initiating proper session handler |
| 35 | - if ($this->config->getHandler() !== null) { |
|
| 36 | - try { |
|
| 36 | + if ($this->config->getHandler() !== null) |
|
| 37 | + { |
|
| 38 | + try |
|
| 39 | + { |
|
| 37 | 40 | $handler = $this->config->getHandler()->resolve($this->factory); |
| 38 | - } catch (\Throwable | ContainerExceptionInterface $e) { |
|
| 41 | + } |
|
| 42 | + catch (\Throwable | ContainerExceptionInterface $e) |
|
| 43 | + { |
|
| 39 | 44 | throw new SessionException($e->getMessage(), (int) $e->getCode(), $e); |
| 40 | 45 | } |
| 41 | 46 | |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | private readonly string $clientSignature, |
| 45 | 45 | private readonly int $lifetime, |
| 46 | 46 | ?string $id = null |
| 47 | - ) { |
|
| 48 | - if (!empty($id) && $this->validID($id)) { |
|
| 47 | + ){ |
|
| 48 | + if (!empty($id) && $this->validID($id)){ |
|
| 49 | 49 | $this->id = $id; |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -67,24 +67,24 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | public function resume(): void |
| 69 | 69 | { |
| 70 | - if ($this->isStarted()) { |
|
| 70 | + if ($this->isStarted()){ |
|
| 71 | 71 | return; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if (!empty($this->id)) { |
|
| 74 | + if (!empty($this->id)){ |
|
| 75 | 75 | \session_id($this->id); |
| 76 | - } else { |
|
| 76 | + }else{ |
|
| 77 | 77 | // always new id |
| 78 | 78 | \session_id(\session_create_id()); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - try { |
|
| 81 | + try{ |
|
| 82 | 82 | \session_start(['use_cookies' => false]); |
| 83 | - } catch (\Throwable $e) { |
|
| 84 | - throw new SessionException('Unable to start session', (int) $e->getCode(), $e); |
|
| 83 | + }catch (\Throwable $e){ |
|
| 84 | + throw new SessionException('Unable to start session', (int)$e->getCode(), $e); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if (empty($this->id)) { |
|
| 87 | + if (empty($this->id)){ |
|
| 88 | 88 | //Sign newly created session |
| 89 | 89 | $_SESSION[self::CLIENT_SIGNATURE] = $this->clientSignature; |
| 90 | 90 | $_SESSION[self::SESSION_CREATED] = \time(); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $this->started = true; |
| 96 | 96 | |
| 97 | 97 | //Ensure that session is valid |
| 98 | - if (!$this->validSession()) { |
|
| 98 | + if (!$this->validSession()){ |
|
| 99 | 99 | $this->invalidateSession(); |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | public function commit(): bool |
| 127 | 127 | { |
| 128 | - if (!$this->isStarted()) { |
|
| 128 | + if (!$this->isStarted()){ |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | public function abort(): bool |
| 139 | 139 | { |
| 140 | - if (!$this->isStarted()) { |
|
| 140 | + if (!$this->isStarted()){ |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -173,12 +173,12 @@ discard block |
||
| 173 | 173 | if ( |
| 174 | 174 | !\array_key_exists(self::CLIENT_SIGNATURE, $_SESSION) |
| 175 | 175 | || !\array_key_exists(self::SESSION_CREATED, $_SESSION) |
| 176 | - ) { |
|
| 176 | + ){ |
|
| 177 | 177 | //Missing session signature or timestamp! |
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ($_SESSION[self::SESSION_CREATED] < \time() - $this->lifetime) { |
|
| 181 | + if ($_SESSION[self::SESSION_CREATED] < \time() - $this->lifetime){ |
|
| 182 | 182 | //Session expired |
| 183 | 183 | return false; |
| 184 | 184 | } |
@@ -45,7 +45,8 @@ discard block |
||
| 45 | 45 | private readonly int $lifetime, |
| 46 | 46 | ?string $id = null |
| 47 | 47 | ) { |
| 48 | - if (!empty($id) && $this->validID($id)) { |
|
| 48 | + if (!empty($id) && $this->validID($id)) |
|
| 49 | + { |
|
| 49 | 50 | $this->id = $id; |
| 50 | 51 | } |
| 51 | 52 | } |
@@ -67,24 +68,32 @@ discard block |
||
| 67 | 68 | |
| 68 | 69 | public function resume(): void |
| 69 | 70 | { |
| 70 | - if ($this->isStarted()) { |
|
| 71 | + if ($this->isStarted()) |
|
| 72 | + { |
|
| 71 | 73 | return; |
| 72 | 74 | } |
| 73 | 75 | |
| 74 | - if (!empty($this->id)) { |
|
| 76 | + if (!empty($this->id)) |
|
| 77 | + { |
|
| 75 | 78 | \session_id($this->id); |
| 76 | - } else { |
|
| 79 | + } |
|
| 80 | + else |
|
| 81 | + { |
|
| 77 | 82 | // always new id |
| 78 | 83 | \session_id(\session_create_id()); |
| 79 | 84 | } |
| 80 | 85 | |
| 81 | - try { |
|
| 86 | + try |
|
| 87 | + { |
|
| 82 | 88 | \session_start(['use_cookies' => false]); |
| 83 | - } catch (\Throwable $e) { |
|
| 89 | + } |
|
| 90 | + catch (\Throwable $e) |
|
| 91 | + { |
|
| 84 | 92 | throw new SessionException('Unable to start session', (int) $e->getCode(), $e); |
| 85 | 93 | } |
| 86 | 94 | |
| 87 | - if (empty($this->id)) { |
|
| 95 | + if (empty($this->id)) |
|
| 96 | + { |
|
| 88 | 97 | //Sign newly created session |
| 89 | 98 | $_SESSION[self::CLIENT_SIGNATURE] = $this->clientSignature; |
| 90 | 99 | $_SESSION[self::SESSION_CREATED] = \time(); |
@@ -95,7 +104,8 @@ discard block |
||
| 95 | 104 | $this->started = true; |
| 96 | 105 | |
| 97 | 106 | //Ensure that session is valid |
| 98 | - if (!$this->validSession()) { |
|
| 107 | + if (!$this->validSession()) |
|
| 108 | + { |
|
| 99 | 109 | $this->invalidateSession(); |
| 100 | 110 | } |
| 101 | 111 | } |
@@ -125,7 +135,8 @@ discard block |
||
| 125 | 135 | |
| 126 | 136 | public function commit(): bool |
| 127 | 137 | { |
| 128 | - if (!$this->isStarted()) { |
|
| 138 | + if (!$this->isStarted()) |
|
| 139 | + { |
|
| 129 | 140 | return false; |
| 130 | 141 | } |
| 131 | 142 | |
@@ -137,7 +148,8 @@ discard block |
||
| 137 | 148 | |
| 138 | 149 | public function abort(): bool |
| 139 | 150 | { |
| 140 | - if (!$this->isStarted()) { |
|
| 151 | + if (!$this->isStarted()) |
|
| 152 | + { |
|
| 141 | 153 | return false; |
| 142 | 154 | } |
| 143 | 155 | |
@@ -178,7 +190,8 @@ discard block |
||
| 178 | 190 | return false; |
| 179 | 191 | } |
| 180 | 192 | |
| 181 | - if ($_SESSION[self::SESSION_CREATED] < \time() - $this->lifetime) { |
|
| 193 | + if ($_SESSION[self::SESSION_CREATED] < \time() - $this->lifetime) |
|
| 194 | + { |
|
| 182 | 195 | //Session expired |
| 183 | 196 | return false; |
| 184 | 197 | } |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | private readonly InvokerInterface $invoker, |
| 23 | 23 | private readonly BinderInterface $binder, |
| 24 | 24 | private readonly AttributeReader $reader |
| 25 | - ) { |
|
| 25 | + ){ |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function createInjection(\ReflectionClass $class, ?string $context = null): UnitEnum |
| 29 | 29 | { |
| 30 | 30 | $attribute = $this->reader->firstClassMetadata($class, ProvideFrom::class); |
| 31 | - if ($attribute === null) { |
|
| 31 | + if ($attribute === null){ |
|
| 32 | 32 | throw new InjectionException( |
| 33 | 33 | \sprintf( |
| 34 | 34 | 'Class `%s` should contain `%s` attribute with defined detector method.', |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | private function validateClass(\ReflectionClass $class, ProvideFrom $attribute): void |
| 64 | 64 | { |
| 65 | - if (!$class->isEnum()) { |
|
| 65 | + if (!$class->isEnum()){ |
|
| 66 | 66 | throw new InjectionException( |
| 67 | 67 | \sprintf( |
| 68 | 68 | 'Class `%s` should be an enum.', |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | ); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if (!$class->hasMethod($attribute->method)) { |
|
| 74 | + if (!$class->hasMethod($attribute->method)){ |
|
| 75 | 75 | throw new InjectionException( |
| 76 | 76 | \sprintf( |
| 77 | 77 | 'Class `%s` does not contain `%s` method.', |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | ); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if (!$class->getMethod($attribute->method)->isStatic()) { |
|
| 84 | + if (!$class->getMethod($attribute->method)->isStatic()){ |
|
| 85 | 85 | throw new InjectionException( |
| 86 | 86 | \sprintf( |
| 87 | 87 | 'Class method `%s::%s` should be static.', |
@@ -28,7 +28,8 @@ discard block |
||
| 28 | 28 | public function createInjection(\ReflectionClass $class, ?string $context = null): UnitEnum |
| 29 | 29 | { |
| 30 | 30 | $attribute = $this->reader->firstClassMetadata($class, ProvideFrom::class); |
| 31 | - if ($attribute === null) { |
|
| 31 | + if ($attribute === null) |
|
| 32 | + { |
|
| 32 | 33 | throw new InjectionException( |
| 33 | 34 | \sprintf( |
| 34 | 35 | 'Class `%s` should contain `%s` attribute with defined detector method.', |
@@ -62,7 +63,8 @@ discard block |
||
| 62 | 63 | */ |
| 63 | 64 | private function validateClass(\ReflectionClass $class, ProvideFrom $attribute): void |
| 64 | 65 | { |
| 65 | - if (!$class->isEnum()) { |
|
| 66 | + if (!$class->isEnum()) |
|
| 67 | + { |
|
| 66 | 68 | throw new InjectionException( |
| 67 | 69 | \sprintf( |
| 68 | 70 | 'Class `%s` should be an enum.', |
@@ -71,7 +73,8 @@ discard block |
||
| 71 | 73 | ); |
| 72 | 74 | } |
| 73 | 75 | |
| 74 | - if (!$class->hasMethod($attribute->method)) { |
|
| 76 | + if (!$class->hasMethod($attribute->method)) |
|
| 77 | + { |
|
| 75 | 78 | throw new InjectionException( |
| 76 | 79 | \sprintf( |
| 77 | 80 | 'Class `%s` does not contain `%s` method.', |
@@ -81,7 +84,8 @@ discard block |
||
| 81 | 84 | ); |
| 82 | 85 | } |
| 83 | 86 | |
| 84 | - if (!$class->getMethod($attribute->method)->isStatic()) { |
|
| 87 | + if (!$class->getMethod($attribute->method)->isStatic()) |
|
| 88 | + { |
|
| 85 | 89 | throw new InjectionException( |
| 86 | 90 | \sprintf( |
| 87 | 91 | 'Class method `%s::%s` should be static.', |
@@ -20,13 +20,13 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function __construct( |
| 22 | 22 | private readonly Handler $coreHandler |
| 23 | - ) { |
|
| 23 | + ){ |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** @inheritdoc */ |
| 27 | 27 | public function push(string $name, mixed $payload = [], ?OptionsInterface $options = null): string |
| 28 | 28 | { |
| 29 | - if ($options !== null && $options->getDelay()) { |
|
| 29 | + if ($options !== null && $options->getDelay()){ |
|
| 30 | 30 | \sleep($options->getDelay()); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -26,7 +26,8 @@ |
||
| 26 | 26 | /** @inheritdoc */ |
| 27 | 27 | public function push(string $name, mixed $payload = [], ?OptionsInterface $options = null): string |
| 28 | 28 | { |
| 29 | - if ($options !== null && $options->getDelay()) { |
|
| 29 | + if ($options !== null && $options->getDelay()) |
|
| 30 | + { |
|
| 30 | 31 | \sleep($options->getDelay()); |
| 31 | 32 | } |
| 32 | 33 | |
@@ -18,24 +18,24 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function __construct( |
| 20 | 20 | private readonly QueueConnectionProviderInterface $queueManager |
| 21 | - ) { |
|
| 21 | + ){ |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function createInjection(ReflectionClass $class, ?string $context = null): QueueInterface |
| 25 | 25 | { |
| 26 | - try { |
|
| 27 | - if ($context === null) { |
|
| 26 | + try{ |
|
| 27 | + if ($context === null){ |
|
| 28 | 28 | $connection = $this->queueManager->getConnection(); |
| 29 | - } else { |
|
| 29 | + }else{ |
|
| 30 | 30 | // Get Queue by context |
| 31 | - try { |
|
| 31 | + try{ |
|
| 32 | 32 | $connection = $this->queueManager->getConnection($context); |
| 33 | - } catch (InvalidArgumentException) { |
|
| 33 | + }catch (InvalidArgumentException){ |
|
| 34 | 34 | // Case when context doesn't match to configured connections |
| 35 | 35 | return $this->queueManager->getConnection(); |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | - } catch (\Throwable $e) { |
|
| 38 | + }catch (\Throwable $e){ |
|
| 39 | 39 | throw new ContainerException(\sprintf("Can't inject the required queue. %s", $e->getMessage()), 0, $e); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -23,19 +23,28 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function createInjection(ReflectionClass $class, ?string $context = null): QueueInterface |
| 25 | 25 | { |
| 26 | - try { |
|
| 27 | - if ($context === null) { |
|
| 26 | + try |
|
| 27 | + { |
|
| 28 | + if ($context === null) |
|
| 29 | + { |
|
| 28 | 30 | $connection = $this->queueManager->getConnection(); |
| 29 | - } else { |
|
| 31 | + } |
|
| 32 | + else |
|
| 33 | + { |
|
| 30 | 34 | // Get Queue by context |
| 31 | - try { |
|
| 35 | + try |
|
| 36 | + { |
|
| 32 | 37 | $connection = $this->queueManager->getConnection($context); |
| 33 | - } catch (InvalidArgumentException) { |
|
| 38 | + } |
|
| 39 | + catch (InvalidArgumentException) |
|
| 40 | + { |
|
| 34 | 41 | // Case when context doesn't match to configured connections |
| 35 | 42 | return $this->queueManager->getConnection(); |
| 36 | 43 | } |
| 37 | 44 | } |
| 38 | - } catch (\Throwable $e) { |
|
| 45 | + } |
|
| 46 | + catch (\Throwable $e) |
|
| 47 | + { |
|
| 39 | 48 | throw new ContainerException(\sprintf("Can't inject the required queue. %s", $e->getMessage()), 0, $e); |
| 40 | 49 | } |
| 41 | 50 | |
@@ -19,14 +19,14 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | abstract public function bucket(?string $name = null): BucketInterface; |
| 21 | 21 | |
| 22 | - public function create(string|\Stringable $id, array $config = []): FileInterface |
|
| 22 | + public function create(string | \Stringable $id, array $config = []): FileInterface |
|
| 23 | 23 | { |
| 24 | 24 | [$name, $pathname] = $this->parseUri($id); |
| 25 | 25 | |
| 26 | 26 | return $this->bucket($name)->create($pathname, $config); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public function write(string|\Stringable $id, mixed $content, array $config = []): FileInterface |
|
| 29 | + public function write(string | \Stringable $id, mixed $content, array $config = []): FileInterface |
|
| 30 | 30 | { |
| 31 | 31 | [$name, $pathname] = $this->parseUri($id); |
| 32 | 32 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function setVisibility( |
| 37 | - string|\Stringable $id, |
|
| 37 | + string | \Stringable $id, |
|
| 38 | 38 | #[ExpectedValues(valuesFromClass: Visibility::class)] |
| 39 | 39 | string $visibility |
| 40 | 40 | ): FileInterface { |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | public function copy( |
| 47 | - string|\Stringable $source, |
|
| 48 | - string|\Stringable $destination, |
|
| 47 | + string | \Stringable $source, |
|
| 48 | + string | \Stringable $destination, |
|
| 49 | 49 | array $config = [] |
| 50 | 50 | ): FileInterface { |
| 51 | 51 | [$sourceName, $sourcePathname] = $this->parseUri($source); |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public function move( |
| 61 | - string|\Stringable $source, |
|
| 62 | - string|\Stringable $destination, |
|
| 61 | + string | \Stringable $source, |
|
| 62 | + string | \Stringable $destination, |
|
| 63 | 63 | array $config = [] |
| 64 | 64 | ): FileInterface { |
| 65 | 65 | [$sourceName, $sourcePathname] = $this->parseUri($source); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | return $sourceStorage->move($sourcePathname, $destPathname, $destStorage, $config); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function delete(string|\Stringable $id, bool $clean = false): void |
|
| 74 | + public function delete(string | \Stringable $id, bool $clean = false): void |
|
| 75 | 75 | { |
| 76 | 76 | [$name, $pathname] = $this->parseUri($id); |
| 77 | 77 | |
@@ -83,5 +83,5 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * {@see Storage::parseUri()} |
| 85 | 85 | */ |
| 86 | - abstract protected function parseUri(string|\Stringable $uri, bool $withScheme = true): array; |
|
| 86 | + abstract protected function parseUri(string | \Stringable $uri, bool $withScheme = true): array; |
|
| 87 | 87 | } |