@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | private function bootResolvers(array $config): void |
| 53 | 53 | { |
| 54 | - foreach ($config['resolvers'] ?? [] as $name => $child) { |
|
| 55 | - if (!\is_string($name)) { |
|
| 54 | + foreach ($config['resolvers'] ?? [] as $name => $child){ |
|
| 55 | + if (!\is_string($name)){ |
|
| 56 | 56 | throw new InvalidArgumentException( |
| 57 | 57 | \vsprintf('Distribution driver config key must be a string, but %s given', [ |
| 58 | 58 | \get_debug_type($child), |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | ); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - if (!\is_array($child)) { |
|
| 63 | + if (!\is_array($child)){ |
|
| 64 | 64 | throw new InvalidArgumentException( |
| 65 | 65 | \vsprintf('Distribution driver config `%s` must be an array, but %s given', [ |
| 66 | 66 | $name, |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | $default = $config['default'] ?? null; |
| 79 | 79 | |
| 80 | - if ($default !== null) { |
|
| 80 | + if ($default !== null){ |
|
| 81 | 81 | // Validate config |
| 82 | - if (!\is_string($default)) { |
|
| 82 | + if (!\is_string($default)){ |
|
| 83 | 83 | throw new InvalidArgumentException( |
| 84 | 84 | \vsprintf('Distribution config default driver must be a string, but %s given', [ |
| 85 | 85 | \get_debug_type($default), |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | private function createResolver(string $name, array $config): UriResolverInterface |
| 95 | 95 | { |
| 96 | - if (!isset($config['type']) || !\is_string($config['type'])) { |
|
| 96 | + if (!isset($config['type']) || !\is_string($config['type'])){ |
|
| 97 | 97 | throw $this->invalidConfigKey($name, 'type', 'string'); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -107,17 +107,17 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | private function createCustomResolver(string $type, string $name, array $config): UriResolverInterface |
| 109 | 109 | { |
| 110 | - if (!\is_subclass_of($type, UriResolverInterface::class, true)) { |
|
| 110 | + if (!\is_subclass_of($type, UriResolverInterface::class, true)){ |
|
| 111 | 111 | throw $this->invalidConfigKey($name, 'type', UriResolverInterface::class); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if (isset($config['options']) && !\is_array($config['options'])) { |
|
| 114 | + if (isset($config['options']) && !\is_array($config['options'])){ |
|
| 115 | 115 | throw $this->invalidConfigKey($name, 'options', 'array'); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - try { |
|
| 118 | + try{ |
|
| 119 | 119 | return new $type(...\array_values($config['options'] ?? [])); |
| 120 | - } catch (\Throwable $e) { |
|
| 120 | + }catch (\Throwable $e){ |
|
| 121 | 121 | $message = 'An error occurred while resolver `%s` initializing: %s'; |
| 122 | 122 | throw new InvalidArgumentException(\sprintf($message, $name, $e->getMessage()), 0, $e); |
| 123 | 123 | } |
@@ -126,36 +126,36 @@ discard block |
||
| 126 | 126 | private function createS3Resolver(string $name, array $config): UriResolverInterface |
| 127 | 127 | { |
| 128 | 128 | // Required config options |
| 129 | - if (!isset($config['region']) || !\is_string($config['region'])) { |
|
| 129 | + if (!isset($config['region']) || !\is_string($config['region'])){ |
|
| 130 | 130 | throw $this->invalidConfigKey($name, 'region', 'string'); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if (!isset($config['key']) || !\is_string($config['key'])) { |
|
| 133 | + if (!isset($config['key']) || !\is_string($config['key'])){ |
|
| 134 | 134 | throw $this->invalidConfigKey($name, 'key', 'string'); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if (!isset($config['secret']) || !\is_string($config['secret'])) { |
|
| 137 | + if (!isset($config['secret']) || !\is_string($config['secret'])){ |
|
| 138 | 138 | throw $this->invalidConfigKey($name, 'secret', 'string'); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if (!isset($config['bucket']) || !\is_string($config['bucket'])) { |
|
| 141 | + if (!isset($config['bucket']) || !\is_string($config['bucket'])){ |
|
| 142 | 142 | throw $this->invalidConfigKey($name, 'bucket', 'string'); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // Optional config options |
| 146 | - if (!\is_string($config['prefix'] ?? '')) { |
|
| 146 | + if (!\is_string($config['prefix'] ?? '')){ |
|
| 147 | 147 | throw $this->invalidConfigKey($name, 'prefix', 'string or null'); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if (!\is_string($config['version'] ?? '')) { |
|
| 150 | + if (!\is_string($config['version'] ?? '')){ |
|
| 151 | 151 | throw $this->invalidConfigKey($name, 'version', 'string or null'); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if (!\is_string($config['token'] ?? '')) { |
|
| 154 | + if (!\is_string($config['token'] ?? '')){ |
|
| 155 | 155 | throw $this->invalidConfigKey($name, 'token', 'string or null'); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if (!\is_int($config['expires'] ?? 0)) { |
|
| 158 | + if (!\is_int($config['expires'] ?? 0)){ |
|
| 159 | 159 | throw $this->invalidConfigKey($name, 'expires', 'positive int (unix timestamp)'); |
| 160 | 160 | } |
| 161 | 161 | |
@@ -180,19 +180,19 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | private function createCloudFrontResolver(string $name, array $config): UriResolverInterface |
| 182 | 182 | { |
| 183 | - if (!isset($config['key']) || !\is_string($config['key'])) { |
|
| 183 | + if (!isset($config['key']) || !\is_string($config['key'])){ |
|
| 184 | 184 | throw $this->invalidConfigKey($name, 'key', 'string'); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if (!isset($config['private']) || !\is_string($config['private'])) { |
|
| 187 | + if (!isset($config['private']) || !\is_string($config['private'])){ |
|
| 188 | 188 | throw $this->invalidConfigKey($name, 'private', 'string value or path to key file'); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if (!isset($config['domain']) || !\is_string($config['domain'])) { |
|
| 191 | + if (!isset($config['domain']) || !\is_string($config['domain'])){ |
|
| 192 | 192 | throw $this->invalidConfigKey($name, 'domain', 'string'); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if (!\is_string($config['prefix'] ?? '')) { |
|
| 195 | + if (!\is_string($config['prefix'] ?? '')){ |
|
| 196 | 196 | throw $this->invalidConfigKey($name, 'prefix', 'string or null'); |
| 197 | 197 | } |
| 198 | 198 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | private function createStaticResolver(string $name, array $config): UriResolverInterface |
| 208 | 208 | { |
| 209 | - if (!isset($config['uri']) || !\is_string($config['uri'])) { |
|
| 209 | + if (!isset($config['uri']) || !\is_string($config['uri'])){ |
|
| 210 | 210 | throw $this->invalidConfigKey($name, 'uri', 'string'); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | private function createUri(string $name, string $uri, array $config): UriInterface |
| 217 | 217 | { |
| 218 | - if (!\is_string($config['factory'] ?? '')) { |
|
| 218 | + if (!\is_string($config['factory'] ?? '')){ |
|
| 219 | 219 | throw $this->invalidConfigKey($name, 'factory', 'string (PSR-7 uri factory implementation)'); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -51,8 +51,10 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | private function bootResolvers(array $config): void |
| 53 | 53 | { |
| 54 | - foreach ($config['resolvers'] ?? [] as $name => $child) { |
|
| 55 | - if (!\is_string($name)) { |
|
| 54 | + foreach ($config['resolvers'] ?? [] as $name => $child) |
|
| 55 | + { |
|
| 56 | + if (!\is_string($name)) |
|
| 57 | + { |
|
| 56 | 58 | throw new InvalidArgumentException( |
| 57 | 59 | \vsprintf('Distribution driver config key must be a string, but %s given', [ |
| 58 | 60 | \get_debug_type($child), |
@@ -60,7 +62,8 @@ discard block |
||
| 60 | 62 | ); |
| 61 | 63 | } |
| 62 | 64 | |
| 63 | - if (!\is_array($child)) { |
|
| 65 | + if (!\is_array($child)) |
|
| 66 | + { |
|
| 64 | 67 | throw new InvalidArgumentException( |
| 65 | 68 | \vsprintf('Distribution driver config `%s` must be an array, but %s given', [ |
| 66 | 69 | $name, |
@@ -77,9 +80,11 @@ discard block |
||
| 77 | 80 | { |
| 78 | 81 | $default = $config['default'] ?? null; |
| 79 | 82 | |
| 80 | - if ($default !== null) { |
|
| 83 | + if ($default !== null) |
|
| 84 | + { |
|
| 81 | 85 | // Validate config |
| 82 | - if (!\is_string($default)) { |
|
| 86 | + if (!\is_string($default)) |
|
| 87 | + { |
|
| 83 | 88 | throw new InvalidArgumentException( |
| 84 | 89 | \vsprintf('Distribution config default driver must be a string, but %s given', [ |
| 85 | 90 | \get_debug_type($default), |
@@ -93,7 +98,8 @@ discard block |
||
| 93 | 98 | |
| 94 | 99 | private function createResolver(string $name, array $config): UriResolverInterface |
| 95 | 100 | { |
| 96 | - if (!isset($config['type']) || !\is_string($config['type'])) { |
|
| 101 | + if (!isset($config['type']) || !\is_string($config['type'])) |
|
| 102 | + { |
|
| 97 | 103 | throw $this->invalidConfigKey($name, 'type', 'string'); |
| 98 | 104 | } |
| 99 | 105 | |
@@ -107,17 +113,22 @@ discard block |
||
| 107 | 113 | |
| 108 | 114 | private function createCustomResolver(string $type, string $name, array $config): UriResolverInterface |
| 109 | 115 | { |
| 110 | - if (!\is_subclass_of($type, UriResolverInterface::class, true)) { |
|
| 116 | + if (!\is_subclass_of($type, UriResolverInterface::class, true)) |
|
| 117 | + { |
|
| 111 | 118 | throw $this->invalidConfigKey($name, 'type', UriResolverInterface::class); |
| 112 | 119 | } |
| 113 | 120 | |
| 114 | - if (isset($config['options']) && !\is_array($config['options'])) { |
|
| 121 | + if (isset($config['options']) && !\is_array($config['options'])) |
|
| 122 | + { |
|
| 115 | 123 | throw $this->invalidConfigKey($name, 'options', 'array'); |
| 116 | 124 | } |
| 117 | 125 | |
| 118 | - try { |
|
| 126 | + try |
|
| 127 | + { |
|
| 119 | 128 | return new $type(...\array_values($config['options'] ?? [])); |
| 120 | - } catch (\Throwable $e) { |
|
| 129 | + } |
|
| 130 | + catch (\Throwable $e) |
|
| 131 | + { |
|
| 121 | 132 | $message = 'An error occurred while resolver `%s` initializing: %s'; |
| 122 | 133 | throw new InvalidArgumentException(\sprintf($message, $name, $e->getMessage()), 0, $e); |
| 123 | 134 | } |
@@ -126,36 +137,44 @@ discard block |
||
| 126 | 137 | private function createS3Resolver(string $name, array $config): UriResolverInterface |
| 127 | 138 | { |
| 128 | 139 | // Required config options |
| 129 | - if (!isset($config['region']) || !\is_string($config['region'])) { |
|
| 140 | + if (!isset($config['region']) || !\is_string($config['region'])) |
|
| 141 | + { |
|
| 130 | 142 | throw $this->invalidConfigKey($name, 'region', 'string'); |
| 131 | 143 | } |
| 132 | 144 | |
| 133 | - if (!isset($config['key']) || !\is_string($config['key'])) { |
|
| 145 | + if (!isset($config['key']) || !\is_string($config['key'])) |
|
| 146 | + { |
|
| 134 | 147 | throw $this->invalidConfigKey($name, 'key', 'string'); |
| 135 | 148 | } |
| 136 | 149 | |
| 137 | - if (!isset($config['secret']) || !\is_string($config['secret'])) { |
|
| 150 | + if (!isset($config['secret']) || !\is_string($config['secret'])) |
|
| 151 | + { |
|
| 138 | 152 | throw $this->invalidConfigKey($name, 'secret', 'string'); |
| 139 | 153 | } |
| 140 | 154 | |
| 141 | - if (!isset($config['bucket']) || !\is_string($config['bucket'])) { |
|
| 155 | + if (!isset($config['bucket']) || !\is_string($config['bucket'])) |
|
| 156 | + { |
|
| 142 | 157 | throw $this->invalidConfigKey($name, 'bucket', 'string'); |
| 143 | 158 | } |
| 144 | 159 | |
| 145 | 160 | // Optional config options |
| 146 | - if (!\is_string($config['prefix'] ?? '')) { |
|
| 161 | + if (!\is_string($config['prefix'] ?? '')) |
|
| 162 | + { |
|
| 147 | 163 | throw $this->invalidConfigKey($name, 'prefix', 'string or null'); |
| 148 | 164 | } |
| 149 | 165 | |
| 150 | - if (!\is_string($config['version'] ?? '')) { |
|
| 166 | + if (!\is_string($config['version'] ?? '')) |
|
| 167 | + { |
|
| 151 | 168 | throw $this->invalidConfigKey($name, 'version', 'string or null'); |
| 152 | 169 | } |
| 153 | 170 | |
| 154 | - if (!\is_string($config['token'] ?? '')) { |
|
| 171 | + if (!\is_string($config['token'] ?? '')) |
|
| 172 | + { |
|
| 155 | 173 | throw $this->invalidConfigKey($name, 'token', 'string or null'); |
| 156 | 174 | } |
| 157 | 175 | |
| 158 | - if (!\is_int($config['expires'] ?? 0)) { |
|
| 176 | + if (!\is_int($config['expires'] ?? 0)) |
|
| 177 | + { |
|
| 159 | 178 | throw $this->invalidConfigKey($name, 'expires', 'positive int (unix timestamp)'); |
| 160 | 179 | } |
| 161 | 180 | |
@@ -180,19 +199,23 @@ discard block |
||
| 180 | 199 | |
| 181 | 200 | private function createCloudFrontResolver(string $name, array $config): UriResolverInterface |
| 182 | 201 | { |
| 183 | - if (!isset($config['key']) || !\is_string($config['key'])) { |
|
| 202 | + if (!isset($config['key']) || !\is_string($config['key'])) |
|
| 203 | + { |
|
| 184 | 204 | throw $this->invalidConfigKey($name, 'key', 'string'); |
| 185 | 205 | } |
| 186 | 206 | |
| 187 | - if (!isset($config['private']) || !\is_string($config['private'])) { |
|
| 207 | + if (!isset($config['private']) || !\is_string($config['private'])) |
|
| 208 | + { |
|
| 188 | 209 | throw $this->invalidConfigKey($name, 'private', 'string value or path to key file'); |
| 189 | 210 | } |
| 190 | 211 | |
| 191 | - if (!isset($config['domain']) || !\is_string($config['domain'])) { |
|
| 212 | + if (!isset($config['domain']) || !\is_string($config['domain'])) |
|
| 213 | + { |
|
| 192 | 214 | throw $this->invalidConfigKey($name, 'domain', 'string'); |
| 193 | 215 | } |
| 194 | 216 | |
| 195 | - if (!\is_string($config['prefix'] ?? '')) { |
|
| 217 | + if (!\is_string($config['prefix'] ?? '')) |
|
| 218 | + { |
|
| 196 | 219 | throw $this->invalidConfigKey($name, 'prefix', 'string or null'); |
| 197 | 220 | } |
| 198 | 221 | |
@@ -206,7 +229,8 @@ discard block |
||
| 206 | 229 | |
| 207 | 230 | private function createStaticResolver(string $name, array $config): UriResolverInterface |
| 208 | 231 | { |
| 209 | - if (!isset($config['uri']) || !\is_string($config['uri'])) { |
|
| 232 | + if (!isset($config['uri']) || !\is_string($config['uri'])) |
|
| 233 | + { |
|
| 210 | 234 | throw $this->invalidConfigKey($name, 'uri', 'string'); |
| 211 | 235 | } |
| 212 | 236 | |
@@ -215,7 +239,8 @@ discard block |
||
| 215 | 239 | |
| 216 | 240 | private function createUri(string $name, string $uri, array $config): UriInterface |
| 217 | 241 | { |
| 218 | - if (!\is_string($config['factory'] ?? '')) { |
|
| 242 | + if (!\is_string($config['factory'] ?? '')) |
|
| 243 | + { |
|
| 219 | 244 | throw $this->invalidConfigKey($name, 'factory', 'string (PSR-7 uri factory implementation)'); |
| 220 | 245 | } |
| 221 | 246 | |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | |
| 73 | 73 | private function resolveExpirationInterval(mixed $expiration): \DateInterval |
| 74 | 74 | { |
| 75 | - if ($expiration === null) { |
|
| 75 | + if ($expiration === null){ |
|
| 76 | 76 | return $this->expiration; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -72,7 +72,8 @@ |
||
| 72 | 72 | |
| 73 | 73 | private function resolveExpirationInterval(mixed $expiration): \DateInterval |
| 74 | 74 | { |
| 75 | - if ($expiration === null) { |
|
| 75 | + if ($expiration === null) |
|
| 76 | + { |
|
| 76 | 77 | return $this->expiration; |
| 77 | 78 | } |
| 78 | 79 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $name ??= $this->default; |
| 38 | 38 | |
| 39 | - if (!isset($this->resolvers[$name])) { |
|
| 39 | + if (!isset($this->resolvers[$name])){ |
|
| 40 | 40 | throw new \InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function add(string $name, UriResolverInterface $resolver, bool $overwrite = false): void |
| 47 | 47 | { |
| 48 | - if ($overwrite === false && isset($this->resolvers[$name])) { |
|
| 48 | + if ($overwrite === false && isset($this->resolvers[$name])){ |
|
| 49 | 49 | throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -36,7 +36,8 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $name ??= $this->default; |
| 38 | 38 | |
| 39 | - if (!isset($this->resolvers[$name])) { |
|
| 39 | + if (!isset($this->resolvers[$name])) |
|
| 40 | + { |
|
| 40 | 41 | throw new \InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
| 41 | 42 | } |
| 42 | 43 | |
@@ -45,7 +46,8 @@ discard block |
||
| 45 | 46 | |
| 46 | 47 | public function add(string $name, UriResolverInterface $resolver, bool $overwrite = false): void |
| 47 | 48 | { |
| 48 | - if ($overwrite === false && isset($this->resolvers[$name])) { |
|
| 49 | + if ($overwrite === false && isset($this->resolvers[$name])) |
|
| 50 | + { |
|
| 49 | 51 | throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
| 50 | 52 | } |
| 51 | 53 | |
@@ -13,6 +13,6 @@ |
||
| 13 | 13 | public bool $bool, |
| 14 | 14 | public array $array = [], |
| 15 | 15 | public ?string $pong = null |
| 16 | - ) { |
|
| 16 | + ){ |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -35,18 +35,18 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function invoke(mixed $target, array $parameters = []): mixed |
| 37 | 37 | { |
| 38 | - if (\is_array($target) && isset($target[1])) { |
|
| 38 | + if (\is_array($target) && isset($target[1])){ |
|
| 39 | 39 | // In a form of resolver and method |
| 40 | 40 | [$resolver, $method] = $target; |
| 41 | 41 | |
| 42 | 42 | // Resolver instance (i.e. [ClassName::class, 'method']) |
| 43 | - if (\is_string($resolver)) { |
|
| 43 | + if (\is_string($resolver)){ |
|
| 44 | 44 | $resolver = $this->container->get($resolver); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - try { |
|
| 47 | + try{ |
|
| 48 | 48 | $method = new \ReflectionMethod($resolver, $method); |
| 49 | - } catch (\ReflectionException $e) { |
|
| 49 | + }catch (\ReflectionException $e){ |
|
| 50 | 50 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if (\is_string($target) && \is_callable($target)) { |
|
| 60 | + if (\is_string($target) && \is_callable($target)){ |
|
| 61 | 61 | $target = $target(...); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if ($target instanceof \Closure) { |
|
| 65 | - try { |
|
| 64 | + if ($target instanceof \Closure){ |
|
| 65 | + try{ |
|
| 66 | 66 | $reflection = new \ReflectionFunction($target); |
| 67 | - } catch (\ReflectionException $e) { |
|
| 67 | + }catch (\ReflectionException $e){ |
|
| 68 | 68 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -35,18 +35,23 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function invoke(mixed $target, array $parameters = []): mixed |
| 37 | 37 | { |
| 38 | - if (\is_array($target) && isset($target[1])) { |
|
| 38 | + if (\is_array($target) && isset($target[1])) |
|
| 39 | + { |
|
| 39 | 40 | // In a form of resolver and method |
| 40 | 41 | [$resolver, $method] = $target; |
| 41 | 42 | |
| 42 | 43 | // Resolver instance (i.e. [ClassName::class, 'method']) |
| 43 | - if (\is_string($resolver)) { |
|
| 44 | + if (\is_string($resolver)) |
|
| 45 | + { |
|
| 44 | 46 | $resolver = $this->container->get($resolver); |
| 45 | 47 | } |
| 46 | 48 | |
| 47 | - try { |
|
| 49 | + try |
|
| 50 | + { |
|
| 48 | 51 | $method = new \ReflectionMethod($resolver, $method); |
| 49 | - } catch (\ReflectionException $e) { |
|
| 52 | + } |
|
| 53 | + catch (\ReflectionException $e) |
|
| 54 | + { |
|
| 50 | 55 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
| 51 | 56 | } |
| 52 | 57 | |
@@ -57,14 +62,19 @@ discard block |
||
| 57 | 62 | ); |
| 58 | 63 | } |
| 59 | 64 | |
| 60 | - if (\is_string($target) && \is_callable($target)) { |
|
| 65 | + if (\is_string($target) && \is_callable($target)) |
|
| 66 | + { |
|
| 61 | 67 | $target = $target(...); |
| 62 | 68 | } |
| 63 | 69 | |
| 64 | - if ($target instanceof \Closure) { |
|
| 65 | - try { |
|
| 70 | + if ($target instanceof \Closure) |
|
| 71 | + { |
|
| 72 | + try |
|
| 73 | + { |
|
| 66 | 74 | $reflection = new \ReflectionFunction($target); |
| 67 | - } catch (\ReflectionException $e) { |
|
| 75 | + } |
|
| 76 | + catch (\ReflectionException $e) |
|
| 77 | + { |
|
| 68 | 78 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
| 69 | 79 | } |
| 70 | 80 | |
@@ -16,8 +16,8 @@ |
||
| 16 | 16 | public function resolveAlias(string $alias): string |
| 17 | 17 | { |
| 18 | 18 | $antiCircleReference = []; |
| 19 | - while (isset($this->config, $this->config['aliases'][$alias]) && \is_string($alias)) { |
|
| 20 | - if (\in_array($alias, $antiCircleReference, true)) { |
|
| 19 | + while (isset($this->config, $this->config['aliases'][$alias]) && \is_string($alias)){ |
|
| 20 | + if (\in_array($alias, $antiCircleReference, true)){ |
|
| 21 | 21 | throw new ContainerException(\sprintf('Circle reference detected for alias `%s`.', $alias)); |
| 22 | 22 | } |
| 23 | 23 | $antiCircleReference[] = $alias; |
@@ -16,8 +16,10 @@ |
||
| 16 | 16 | public function resolveAlias(string $alias): string |
| 17 | 17 | { |
| 18 | 18 | $antiCircleReference = []; |
| 19 | - while (isset($this->config, $this->config['aliases'][$alias]) && \is_string($alias)) { |
|
| 20 | - if (\in_array($alias, $antiCircleReference, true)) { |
|
| 19 | + while (isset($this->config, $this->config['aliases'][$alias]) && \is_string($alias)) |
|
| 20 | + { |
|
| 21 | + if (\in_array($alias, $antiCircleReference, true)) |
|
| 22 | + { |
|
| 21 | 23 | throw new ContainerException(\sprintf('Circle reference detected for alias `%s`.', $alias)); |
| 22 | 24 | } |
| 23 | 25 | $antiCircleReference[] = $alias; |
@@ -23,5 +23,5 @@ |
||
| 23 | 23 | * |
| 24 | 24 | * @throws NotCallableException |
| 25 | 25 | */ |
| 26 | - public function invoke(array|callable|string $target, array $parameters = []): mixed; |
|
| 26 | + public function invoke(array | callable | string $target, array $parameters = []): mixed; |
|
| 27 | 27 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | |
| 49 | 49 | public function offsetGet(mixed $offset): mixed |
| 50 | 50 | { |
| 51 | - if (!$this->offsetExists($offset)) { |
|
| 51 | + if (!$this->offsetExists($offset)){ |
|
| 52 | 52 | throw new ConfigException(\sprintf("Undefined configuration key '%s'", $offset)); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -48,7 +48,8 @@ |
||
| 48 | 48 | |
| 49 | 49 | public function offsetGet(mixed $offset): mixed |
| 50 | 50 | { |
| 51 | - if (!$this->offsetExists($offset)) { |
|
| 51 | + if (!$this->offsetExists($offset)) |
|
| 52 | + { |
|
| 52 | 53 | throw new ConfigException(\sprintf("Undefined configuration key '%s'", $offset)); |
| 53 | 54 | } |
| 54 | 55 | |
@@ -127,11 +127,13 @@ |
||
| 127 | 127 | |
| 128 | 128 | public function setDelay(\DateInterval|\DateTimeInterface|int $delay): self |
| 129 | 129 | { |
| 130 | - if ($delay instanceof \DateInterval) { |
|
| 130 | + if ($delay instanceof \DateInterval) |
|
| 131 | + { |
|
| 131 | 132 | $delay = (new \DateTimeImmutable('NOW'))->add($delay); |
| 132 | 133 | } |
| 133 | 134 | |
| 134 | - if ($delay instanceof \DateTimeInterface) { |
|
| 135 | + if ($delay instanceof \DateTimeInterface) |
|
| 136 | + { |
|
| 135 | 137 | $delay = \max(0, $delay->getTimestamp() - \time()); |
| 136 | 138 | } |
| 137 | 139 | |
@@ -15,10 +15,10 @@ discard block |
||
| 15 | 15 | private ?string $replyTo = null; |
| 16 | 16 | private array $options = []; |
| 17 | 17 | |
| 18 | - public function __construct(string $subject, string|array $to, array $data = []) |
|
| 18 | + public function __construct(string $subject, string | array $to, array $data = []) |
|
| 19 | 19 | { |
| 20 | 20 | $this->setSubject($subject); |
| 21 | - $this->setTo(...(array) $to); |
|
| 21 | + $this->setTo(...(array)$to); |
|
| 22 | 22 | $this->setData($data); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | return $this->options; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function setDelay(\DateInterval|\DateTimeInterface|int $delay): self |
|
| 128 | + public function setDelay(\DateInterval | \DateTimeInterface | int $delay): self |
|
| 129 | 129 | { |
| 130 | - if ($delay instanceof \DateInterval) { |
|
| 130 | + if ($delay instanceof \DateInterval){ |
|
| 131 | 131 | $delay = (new \DateTimeImmutable('NOW'))->add($delay); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if ($delay instanceof \DateTimeInterface) { |
|
| 134 | + if ($delay instanceof \DateTimeInterface){ |
|
| 135 | 135 | $delay = \max(0, $delay->getTimestamp() - \time()); |
| 136 | 136 | } |
| 137 | 137 | |