@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | */ |
45 | 45 | private function registerResolver(Container $app): void |
46 | 46 | { |
47 | - $app->bindSingleton(UriResolverInterface::class, static function (DistributionInterface $manager) { |
|
47 | + $app->bindSingleton(UriResolverInterface::class, static function (DistributionInterface $manager){ |
|
48 | 48 | return $manager->resolver(); |
49 | 49 | }); |
50 | 50 | |
51 | - $app->bindSingleton(UriResolver::class, static function (Container $app) { |
|
51 | + $app->bindSingleton(UriResolver::class, static function (Container $app){ |
|
52 | 52 | return $app->get(UriResolverInterface::class); |
53 | 53 | }); |
54 | 54 | } |
@@ -58,21 +58,21 @@ discard block |
||
58 | 58 | */ |
59 | 59 | private function registerManager(Container $app): void |
60 | 60 | { |
61 | - $app->bindSingleton(DistributionInterface::class, static function (DistributionConfig $config) { |
|
61 | + $app->bindSingleton(DistributionInterface::class, static function (DistributionConfig $config){ |
|
62 | 62 | $manager = new Manager($config->getDefaultDriver()); |
63 | 63 | |
64 | - foreach ($config->getResolvers() as $name => $resolver) { |
|
64 | + foreach ($config->getResolvers() as $name => $resolver){ |
|
65 | 65 | $manager->add($name, $resolver); |
66 | 66 | } |
67 | 67 | |
68 | 68 | return $manager; |
69 | 69 | }); |
70 | 70 | |
71 | - $app->bindSingleton(MutableDistributionInterface::class, static function (Container $app) { |
|
71 | + $app->bindSingleton(MutableDistributionInterface::class, static function (Container $app){ |
|
72 | 72 | return $app->get(DistributionInterface::class); |
73 | 73 | }); |
74 | 74 | |
75 | - $app->bindSingleton(Manager::class, static function (Container $app) { |
|
75 | + $app->bindSingleton(Manager::class, static function (Container $app){ |
|
76 | 76 | return $app->get(DistributionInterface::class); |
77 | 77 | }); |
78 | 78 | } |
@@ -44,11 +44,13 @@ discard block |
||
44 | 44 | */ |
45 | 45 | private function registerResolver(Container $app): void |
46 | 46 | { |
47 | - $app->bindSingleton(UriResolverInterface::class, static function (DistributionInterface $manager) { |
|
47 | + $app->bindSingleton(UriResolverInterface::class, static function (DistributionInterface $manager) |
|
48 | + { |
|
48 | 49 | return $manager->resolver(); |
49 | 50 | }); |
50 | 51 | |
51 | - $app->bindSingleton(UriResolver::class, static function (Container $app) { |
|
52 | + $app->bindSingleton(UriResolver::class, static function (Container $app) |
|
53 | + { |
|
52 | 54 | return $app->get(UriResolverInterface::class); |
53 | 55 | }); |
54 | 56 | } |
@@ -58,21 +60,25 @@ discard block |
||
58 | 60 | */ |
59 | 61 | private function registerManager(Container $app): void |
60 | 62 | { |
61 | - $app->bindSingleton(DistributionInterface::class, static function (DistributionConfig $config) { |
|
63 | + $app->bindSingleton(DistributionInterface::class, static function (DistributionConfig $config) |
|
64 | + { |
|
62 | 65 | $manager = new Manager($config->getDefaultDriver()); |
63 | 66 | |
64 | - foreach ($config->getResolvers() as $name => $resolver) { |
|
67 | + foreach ($config->getResolvers() as $name => $resolver) |
|
68 | + { |
|
65 | 69 | $manager->add($name, $resolver); |
66 | 70 | } |
67 | 71 | |
68 | 72 | return $manager; |
69 | 73 | }); |
70 | 74 | |
71 | - $app->bindSingleton(MutableDistributionInterface::class, static function (Container $app) { |
|
75 | + $app->bindSingleton(MutableDistributionInterface::class, static function (Container $app) |
|
76 | + { |
|
72 | 77 | return $app->get(DistributionInterface::class); |
73 | 78 | }); |
74 | 79 | |
75 | - $app->bindSingleton(Manager::class, static function (Container $app) { |
|
80 | + $app->bindSingleton(Manager::class, static function (Container $app) |
|
81 | + { |
|
76 | 82 | return $app->get(DistributionInterface::class); |
77 | 83 | }); |
78 | 84 | } |
@@ -29,11 +29,11 @@ |
||
29 | 29 | */ |
30 | 30 | private function writeJson(ResponseInterface $response, $payload, int $code = 200): ResponseInterface |
31 | 31 | { |
32 | - if ($payload instanceof JsonSerializable) { |
|
32 | + if ($payload instanceof JsonSerializable){ |
|
33 | 33 | $payload = $payload->jsonSerialize(); |
34 | 34 | } |
35 | 35 | |
36 | - if (is_array($payload) && isset($payload['status']) && is_int($payload['status'])) { |
|
36 | + if (is_array($payload) && isset($payload['status']) && is_int($payload['status'])){ |
|
37 | 37 | $code = $payload['status']; |
38 | 38 | } |
39 | 39 |
@@ -29,11 +29,13 @@ |
||
29 | 29 | */ |
30 | 30 | private function writeJson(ResponseInterface $response, $payload, int $code = 200): ResponseInterface |
31 | 31 | { |
32 | - if ($payload instanceof JsonSerializable) { |
|
32 | + if ($payload instanceof JsonSerializable) |
|
33 | + { |
|
33 | 34 | $payload = $payload->jsonSerialize(); |
34 | 35 | } |
35 | 36 | |
36 | - if (is_array($payload) && isset($payload['status']) && is_int($payload['status'])) { |
|
37 | + if (is_array($payload) && isset($payload['status']) && is_int($payload['status'])) |
|
38 | + { |
|
37 | 39 | $code = $payload['status']; |
38 | 40 | } |
39 | 41 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | ? $class::DESCRIPTION |
43 | 43 | : '', |
44 | 44 | false, |
45 | - function () use ($class): SymfonyCommand { |
|
45 | + function () use ($class) : SymfonyCommand { |
|
46 | 46 | $command = $this->container->get($class); |
47 | 47 | $command->setContainer($this->container); |
48 | 48 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | public function locateCommands(): array |
42 | 42 | { |
43 | 43 | $commands = []; |
44 | - foreach ($this->commands as $command) { |
|
44 | + foreach ($this->commands as $command){ |
|
45 | 45 | $commands[] = $this->supportsLazyLoading($command) |
46 | 46 | ? $this->createLazyCommand($command) |
47 | 47 | : $this->container->get($command); |
@@ -41,7 +41,8 @@ |
||
41 | 41 | public function locateCommands(): array |
42 | 42 | { |
43 | 43 | $commands = []; |
44 | - foreach ($this->commands as $command) { |
|
44 | + foreach ($this->commands as $command) |
|
45 | + { |
|
45 | 46 | $commands[] = $this->supportsLazyLoading($command) |
46 | 47 | ? $this->createLazyCommand($command) |
47 | 48 | : $this->container->get($command); |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | public function exists($value, string $role, ?string $field = null, bool $ignoreCase = false): bool |
43 | 43 | { |
44 | 44 | $repository = $this->orm->getRepository($role); |
45 | - if ($field === null) { |
|
45 | + if ($field === null){ |
|
46 | 46 | return $repository->findByPK($value) !== null; |
47 | 47 | } |
48 | 48 | |
49 | - if ($ignoreCase && $repository instanceof Repository) { |
|
49 | + if ($ignoreCase && $repository instanceof Repository){ |
|
50 | 50 | return $this |
51 | 51 | ->addCaseInsensitiveWhere($repository->select(), $field, $value) |
52 | 52 | ->fetchOne() !== null; |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | $values = $this->withValues($withFields); |
69 | 69 | $values[$field] = $value; |
70 | 70 | |
71 | - if ($this->isProvidedByContext($role, $values)) { |
|
71 | + if ($this->isProvidedByContext($role, $values)){ |
|
72 | 72 | return true; |
73 | 73 | } |
74 | 74 | |
75 | 75 | $repository = $this->orm->getRepository($role); |
76 | 76 | |
77 | - if ($ignoreCase && $repository instanceof Repository) { |
|
77 | + if ($ignoreCase && $repository instanceof Repository){ |
|
78 | 78 | $select = $repository->select(); |
79 | 79 | |
80 | - foreach ($values as $field => $fieldValue) { |
|
80 | + foreach ($values as $field => $fieldValue){ |
|
81 | 81 | $this->addCaseInsensitiveWhere($select, $field, $fieldValue); |
82 | 82 | } |
83 | 83 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | private function withValues(array $fields): array |
95 | 95 | { |
96 | 96 | $values = []; |
97 | - foreach ($fields as $field) { |
|
98 | - if ($this->getValidator()->hasValue($field)) { |
|
97 | + foreach ($fields as $field){ |
|
98 | + if ($this->getValidator()->hasValue($field)){ |
|
99 | 99 | $values[$field] = $this->getValidator()->getValue($field); |
100 | 100 | } |
101 | 101 | } |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | private function isProvidedByContext(string $role, array $values): bool |
112 | 112 | { |
113 | 113 | $entity = $this->getValidator()->getContext(); |
114 | - if (!is_object($entity) || !$this->orm->getHeap()->has($entity)) { |
|
114 | + if (!is_object($entity) || !$this->orm->getHeap()->has($entity)){ |
|
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | |
118 | 118 | $extract = $this->orm->getMapper($role)->extract($entity); |
119 | - foreach ($values as $field => $value) { |
|
120 | - if (!isset($extract[$field]) || $extract[$field] !== $value) { |
|
119 | + foreach ($values as $field => $value){ |
|
120 | + if (!isset($extract[$field]) || $extract[$field] !== $value){ |
|
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | private function addCaseInsensitiveWhere(Select $select, string $field, $value): Select |
135 | 135 | { |
136 | - if (!is_string($value)) { |
|
136 | + if (!is_string($value)){ |
|
137 | 137 | return $select->where($field, $value); |
138 | 138 | } |
139 | 139 |
@@ -42,11 +42,13 @@ discard block |
||
42 | 42 | public function exists($value, string $role, ?string $field = null, bool $ignoreCase = false): bool |
43 | 43 | { |
44 | 44 | $repository = $this->orm->getRepository($role); |
45 | - if ($field === null) { |
|
45 | + if ($field === null) |
|
46 | + { |
|
46 | 47 | return $repository->findByPK($value) !== null; |
47 | 48 | } |
48 | 49 | |
49 | - if ($ignoreCase && $repository instanceof Repository) { |
|
50 | + if ($ignoreCase && $repository instanceof Repository) |
|
51 | + { |
|
50 | 52 | return $this |
51 | 53 | ->addCaseInsensitiveWhere($repository->select(), $field, $value) |
52 | 54 | ->fetchOne() !== null; |
@@ -68,16 +70,19 @@ discard block |
||
68 | 70 | $values = $this->withValues($withFields); |
69 | 71 | $values[$field] = $value; |
70 | 72 | |
71 | - if ($this->isProvidedByContext($role, $values)) { |
|
73 | + if ($this->isProvidedByContext($role, $values)) |
|
74 | + { |
|
72 | 75 | return true; |
73 | 76 | } |
74 | 77 | |
75 | 78 | $repository = $this->orm->getRepository($role); |
76 | 79 | |
77 | - if ($ignoreCase && $repository instanceof Repository) { |
|
80 | + if ($ignoreCase && $repository instanceof Repository) |
|
81 | + { |
|
78 | 82 | $select = $repository->select(); |
79 | 83 | |
80 | - foreach ($values as $field => $fieldValue) { |
|
84 | + foreach ($values as $field => $fieldValue) |
|
85 | + { |
|
81 | 86 | $this->addCaseInsensitiveWhere($select, $field, $fieldValue); |
82 | 87 | } |
83 | 88 | |
@@ -94,8 +99,10 @@ discard block |
||
94 | 99 | private function withValues(array $fields): array |
95 | 100 | { |
96 | 101 | $values = []; |
97 | - foreach ($fields as $field) { |
|
98 | - if ($this->getValidator()->hasValue($field)) { |
|
102 | + foreach ($fields as $field) |
|
103 | + { |
|
104 | + if ($this->getValidator()->hasValue($field)) |
|
105 | + { |
|
99 | 106 | $values[$field] = $this->getValidator()->getValue($field); |
100 | 107 | } |
101 | 108 | } |
@@ -111,13 +118,16 @@ discard block |
||
111 | 118 | private function isProvidedByContext(string $role, array $values): bool |
112 | 119 | { |
113 | 120 | $entity = $this->getValidator()->getContext(); |
114 | - if (!is_object($entity) || !$this->orm->getHeap()->has($entity)) { |
|
121 | + if (!is_object($entity) || !$this->orm->getHeap()->has($entity)) |
|
122 | + { |
|
115 | 123 | return false; |
116 | 124 | } |
117 | 125 | |
118 | 126 | $extract = $this->orm->getMapper($role)->extract($entity); |
119 | - foreach ($values as $field => $value) { |
|
120 | - if (!isset($extract[$field]) || $extract[$field] !== $value) { |
|
127 | + foreach ($values as $field => $value) |
|
128 | + { |
|
129 | + if (!isset($extract[$field]) || $extract[$field] !== $value) |
|
130 | + { |
|
121 | 131 | return false; |
122 | 132 | } |
123 | 133 | } |
@@ -133,7 +143,8 @@ discard block |
||
133 | 143 | */ |
134 | 144 | private function addCaseInsensitiveWhere(Select $select, string $field, $value): Select |
135 | 145 | { |
136 | - if (!is_string($value)) { |
|
146 | + if (!is_string($value)) |
|
147 | + { |
|
137 | 148 | return $select->where($field, $value); |
138 | 149 | } |
139 | 150 |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | */ |
104 | 104 | private function bootStorages(array $config): void |
105 | 105 | { |
106 | - foreach ($config['buckets'] as $name => $bucket) { |
|
107 | - if (!\is_string($name)) { |
|
106 | + foreach ($config['buckets'] as $name => $bucket){ |
|
107 | + if (!\is_string($name)){ |
|
108 | 108 | throw new InvalidArgumentException( |
109 | 109 | \vsprintf('Storage bucket config key must be a string, but %s defined', [ |
110 | 110 | \get_debug_type($name), |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | $serverName = $bucket['server'] ?? null; |
116 | - if (!\is_string($serverName)) { |
|
116 | + if (!\is_string($serverName)){ |
|
117 | 117 | throw new InvalidArgumentException( |
118 | 118 | \vsprintf('Storage bucket `%s.server` config key required and must be a string, but %s defined', [ |
119 | 119 | $name, |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | $server = $config['servers'][$serverName] ?? null; |
126 | - if (!\is_array($server)) { |
|
126 | + if (!\is_array($server)){ |
|
127 | 127 | throw new InvalidArgumentException( |
128 | 128 | \vsprintf('Storage bucket `%s` relates to non-existing server `%s`', [ |
129 | 129 | $name, |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | $adapter = $server['adapter'] ?? null; |
136 | - if (!\is_string($adapter)) { |
|
136 | + if (!\is_string($adapter)){ |
|
137 | 137 | throw new InvalidArgumentException( |
138 | 138 | \vsprintf('Storage server `%s.adapter` config key required and must be a string, but %s defined', [ |
139 | 139 | $serverName, |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | $this->adapters[$name] = $adapter; |
148 | 148 | |
149 | - if (isset($bucket['distribution'])) { |
|
149 | + if (isset($bucket['distribution'])){ |
|
150 | 150 | $this->distributions[$name] = $bucket['distribution']; |
151 | 151 | } |
152 | 152 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | private function createAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter |
162 | 162 | { |
163 | - switch ($server['adapter']) { |
|
163 | + switch ($server['adapter']){ |
|
164 | 164 | case 'local': |
165 | 165 | return $this->createLocalAdapter($serverName, $bucket, $server); |
166 | 166 | |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | */ |
185 | 185 | private function createS3Adapter(string $serverName, array $bucket, array $server, bool $async): FilesystemAdapter |
186 | 186 | { |
187 | - if (!\class_exists(Credentials::class)) { |
|
187 | + if (!\class_exists(Credentials::class)){ |
|
188 | 188 | throw new ConfigException( |
189 | - 'Can not create AWS credentials while creating "' . $serverName . '" server. ' |
|
189 | + 'Can not create AWS credentials while creating "'.$serverName.'" server. ' |
|
190 | 190 | . 'Perhaps you forgot to install the "league/flysystem-aws-s3-v3" package?' |
191 | 191 | ); |
192 | 192 | } |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | $name = $bucket['bucket'] ?? $server['bucket']; |
207 | 207 | $visibility = $bucket['visibility'] ?? $server['bucket'] ?? Visibility::VISIBILITY_PUBLIC; |
208 | 208 | |
209 | - if ($async) { |
|
210 | - if (!\class_exists(AsyncAwsS3Adapter::class)) { |
|
209 | + if ($async){ |
|
210 | + if (!\class_exists(AsyncAwsS3Adapter::class)){ |
|
211 | 211 | throw new InvalidArgumentException( |
212 | 212 | 'Can not create async S3 client, please install "league/flysystem-async-aws-s3"' |
213 | 213 | ); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | ); |
224 | 224 | } |
225 | 225 | |
226 | - if (!\class_exists(AwsS3V3Adapter::class)) { |
|
226 | + if (!\class_exists(AwsS3V3Adapter::class)){ |
|
227 | 227 | throw new InvalidArgumentException( |
228 | 228 | 'Can not create S3 client, please install "league/flysystem-aws-s3-v3"' |
229 | 229 | ); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | private function createLocalAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter |
249 | 249 | { |
250 | - if (!\is_string($server['directory'] ?? null)) { |
|
250 | + if (!\is_string($server['directory'] ?? null)){ |
|
251 | 251 | throw new InvalidArgumentException( |
252 | 252 | \vsprintf('Storage server `%s.directory` config key required and must be a string, but %s defined', [ |
253 | 253 | $serverName, |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $adapter = $server['adapter']; |
283 | 283 | $isFilesystemAdapter = \is_subclass_of($adapter, FilesystemAdapter::class, true); |
284 | 284 | |
285 | - if (!$isFilesystemAdapter) { |
|
285 | + if (!$isFilesystemAdapter){ |
|
286 | 286 | throw new InvalidArgumentException( |
287 | 287 | \vsprintf('Storage server `%s` must be a class string of %s, but `%s` defined', [ |
288 | 288 | $serverName, |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | ); |
293 | 293 | } |
294 | 294 | |
295 | - try { |
|
295 | + try{ |
|
296 | 296 | return new $adapter(...\array_values($server['options'] ?? [])); |
297 | - } catch (\Throwable $e) { |
|
297 | + }catch (\Throwable $e){ |
|
298 | 298 | $message = 'An error occurred while server `%s` initializing: %s'; |
299 | 299 | throw new InvalidArgumentException(\sprintf($message, $serverName, $e->getMessage()), 0, $e); |
300 | 300 | } |
@@ -103,8 +103,10 @@ discard block |
||
103 | 103 | */ |
104 | 104 | private function bootStorages(array $config): void |
105 | 105 | { |
106 | - foreach ($config['buckets'] as $name => $bucket) { |
|
107 | - if (!\is_string($name)) { |
|
106 | + foreach ($config['buckets'] as $name => $bucket) |
|
107 | + { |
|
108 | + if (!\is_string($name)) |
|
109 | + { |
|
108 | 110 | throw new InvalidArgumentException( |
109 | 111 | \vsprintf('Storage bucket config key must be a string, but %s defined', [ |
110 | 112 | \get_debug_type($name), |
@@ -113,7 +115,8 @@ discard block |
||
113 | 115 | } |
114 | 116 | |
115 | 117 | $serverName = $bucket['server'] ?? null; |
116 | - if (!\is_string($serverName)) { |
|
118 | + if (!\is_string($serverName)) |
|
119 | + { |
|
117 | 120 | throw new InvalidArgumentException( |
118 | 121 | \vsprintf('Storage bucket `%s.server` config key required and must be a string, but %s defined', [ |
119 | 122 | $name, |
@@ -123,7 +126,8 @@ discard block |
||
123 | 126 | } |
124 | 127 | |
125 | 128 | $server = $config['servers'][$serverName] ?? null; |
126 | - if (!\is_array($server)) { |
|
129 | + if (!\is_array($server)) |
|
130 | + { |
|
127 | 131 | throw new InvalidArgumentException( |
128 | 132 | \vsprintf('Storage bucket `%s` relates to non-existing server `%s`', [ |
129 | 133 | $name, |
@@ -133,7 +137,8 @@ discard block |
||
133 | 137 | } |
134 | 138 | |
135 | 139 | $adapter = $server['adapter'] ?? null; |
136 | - if (!\is_string($adapter)) { |
|
140 | + if (!\is_string($adapter)) |
|
141 | + { |
|
137 | 142 | throw new InvalidArgumentException( |
138 | 143 | \vsprintf('Storage server `%s.adapter` config key required and must be a string, but %s defined', [ |
139 | 144 | $serverName, |
@@ -146,7 +151,8 @@ discard block |
||
146 | 151 | |
147 | 152 | $this->adapters[$name] = $adapter; |
148 | 153 | |
149 | - if (isset($bucket['distribution'])) { |
|
154 | + if (isset($bucket['distribution'])) |
|
155 | + { |
|
150 | 156 | $this->distributions[$name] = $bucket['distribution']; |
151 | 157 | } |
152 | 158 | } |
@@ -160,7 +166,8 @@ discard block |
||
160 | 166 | */ |
161 | 167 | private function createAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter |
162 | 168 | { |
163 | - switch ($server['adapter']) { |
|
169 | + switch ($server['adapter']) |
|
170 | + { |
|
164 | 171 | case 'local': |
165 | 172 | return $this->createLocalAdapter($serverName, $bucket, $server); |
166 | 173 | |
@@ -184,7 +191,8 @@ discard block |
||
184 | 191 | */ |
185 | 192 | private function createS3Adapter(string $serverName, array $bucket, array $server, bool $async): FilesystemAdapter |
186 | 193 | { |
187 | - if (!\class_exists(Credentials::class)) { |
|
194 | + if (!\class_exists(Credentials::class)) |
|
195 | + { |
|
188 | 196 | throw new ConfigException( |
189 | 197 | 'Can not create AWS credentials while creating "' . $serverName . '" server. ' |
190 | 198 | . 'Perhaps you forgot to install the "league/flysystem-aws-s3-v3" package?' |
@@ -206,8 +214,10 @@ discard block |
||
206 | 214 | $name = $bucket['bucket'] ?? $server['bucket']; |
207 | 215 | $visibility = $bucket['visibility'] ?? $server['bucket'] ?? Visibility::VISIBILITY_PUBLIC; |
208 | 216 | |
209 | - if ($async) { |
|
210 | - if (!\class_exists(AsyncAwsS3Adapter::class)) { |
|
217 | + if ($async) |
|
218 | + { |
|
219 | + if (!\class_exists(AsyncAwsS3Adapter::class)) |
|
220 | + { |
|
211 | 221 | throw new InvalidArgumentException( |
212 | 222 | 'Can not create async S3 client, please install "league/flysystem-async-aws-s3"' |
213 | 223 | ); |
@@ -223,7 +233,8 @@ discard block |
||
223 | 233 | ); |
224 | 234 | } |
225 | 235 | |
226 | - if (!\class_exists(AwsS3V3Adapter::class)) { |
|
236 | + if (!\class_exists(AwsS3V3Adapter::class)) |
|
237 | + { |
|
227 | 238 | throw new InvalidArgumentException( |
228 | 239 | 'Can not create S3 client, please install "league/flysystem-aws-s3-v3"' |
229 | 240 | ); |
@@ -247,7 +258,8 @@ discard block |
||
247 | 258 | */ |
248 | 259 | private function createLocalAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter |
249 | 260 | { |
250 | - if (!\is_string($server['directory'] ?? null)) { |
|
261 | + if (!\is_string($server['directory'] ?? null)) |
|
262 | + { |
|
251 | 263 | throw new InvalidArgumentException( |
252 | 264 | \vsprintf('Storage server `%s.directory` config key required and must be a string, but %s defined', [ |
253 | 265 | $serverName, |
@@ -282,7 +294,8 @@ discard block |
||
282 | 294 | $adapter = $server['adapter']; |
283 | 295 | $isFilesystemAdapter = \is_subclass_of($adapter, FilesystemAdapter::class, true); |
284 | 296 | |
285 | - if (!$isFilesystemAdapter) { |
|
297 | + if (!$isFilesystemAdapter) |
|
298 | + { |
|
286 | 299 | throw new InvalidArgumentException( |
287 | 300 | \vsprintf('Storage server `%s` must be a class string of %s, but `%s` defined', [ |
288 | 301 | $serverName, |
@@ -292,9 +305,12 @@ discard block |
||
292 | 305 | ); |
293 | 306 | } |
294 | 307 | |
295 | - try { |
|
308 | + try |
|
309 | + { |
|
296 | 310 | return new $adapter(...\array_values($server['options'] ?? [])); |
297 | - } catch (\Throwable $e) { |
|
311 | + } |
|
312 | + catch (\Throwable $e) |
|
313 | + { |
|
298 | 314 | $message = 'An error occurred while server `%s` initializing: %s'; |
299 | 315 | throw new InvalidArgumentException(\sprintf($message, $serverName, $e->getMessage()), 0, $e); |
300 | 316 | } |
@@ -75,6 +75,6 @@ |
||
75 | 75 | $prefix = \trim($this->host->getPath(), self::URI_PATH_DELIMITER); |
76 | 76 | $file = \trim($file, self::URI_PATH_DELIMITER); |
77 | 77 | |
78 | - return self::URI_PATH_DELIMITER . ('' === $prefix ? '' : $prefix . self::URI_PATH_DELIMITER) . $file; |
|
78 | + return self::URI_PATH_DELIMITER.('' === $prefix ? '' : $prefix.self::URI_PATH_DELIMITER).$file; |
|
79 | 79 | } |
80 | 80 | } |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | |
44 | 44 | $http->setHandler( |
45 | 45 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
46 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
46 | + if ($request->getAttribute('authContext')->getToken() === null){ |
|
47 | 47 | echo 'no token'; |
48 | - } else { |
|
48 | + }else{ |
|
49 | 49 | echo $request->getAttribute('authContext')->getToken()->getID(); |
50 | 50 | echo ':'; |
51 | 51 | echo json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | |
68 | 68 | $http->setHandler( |
69 | 69 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
70 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
70 | + if ($request->getAttribute('authContext')->getToken() === null){ |
|
71 | 71 | echo 'no token'; |
72 | - } else { |
|
72 | + }else{ |
|
73 | 73 | echo $request->getAttribute('authContext')->getToken()->getID(); |
74 | 74 | echo ':'; |
75 | 75 | echo json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | |
91 | 91 | $http->setHandler( |
92 | 92 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
93 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
93 | + if ($request->getAttribute('authContext')->getToken() === null){ |
|
94 | 94 | echo 'no token'; |
95 | - } else { |
|
95 | + }else{ |
|
96 | 96 | echo $request->getAttribute('authContext')->getToken()->getID(); |
97 | 97 | echo ':'; |
98 | 98 | echo json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -43,9 +43,12 @@ discard block |
||
43 | 43 | |
44 | 44 | $http->setHandler( |
45 | 45 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
46 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
46 | + if ($request->getAttribute('authContext')->getToken() === null) |
|
47 | + { |
|
47 | 48 | echo 'no token'; |
48 | - } else { |
|
49 | + } |
|
50 | + else |
|
51 | + { |
|
49 | 52 | echo $request->getAttribute('authContext')->getToken()->getID(); |
50 | 53 | echo ':'; |
51 | 54 | echo json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -67,9 +70,12 @@ discard block |
||
67 | 70 | |
68 | 71 | $http->setHandler( |
69 | 72 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
70 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
73 | + if ($request->getAttribute('authContext')->getToken() === null) |
|
74 | + { |
|
71 | 75 | echo 'no token'; |
72 | - } else { |
|
76 | + } |
|
77 | + else |
|
78 | + { |
|
73 | 79 | echo $request->getAttribute('authContext')->getToken()->getID(); |
74 | 80 | echo ':'; |
75 | 81 | echo json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -90,9 +96,12 @@ discard block |
||
90 | 96 | |
91 | 97 | $http->setHandler( |
92 | 98 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
93 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
99 | + if ($request->getAttribute('authContext')->getToken() === null) |
|
100 | + { |
|
94 | 101 | echo 'no token'; |
95 | - } else { |
|
102 | + } |
|
103 | + else |
|
104 | + { |
|
96 | 105 | echo $request->getAttribute('authContext')->getToken()->getID(); |
97 | 106 | echo ':'; |
98 | 107 | echo json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function fetchToken(Request $request): ?string |
43 | 43 | { |
44 | - if ($request->hasHeader($this->header)) { |
|
44 | + if ($request->hasHeader($this->header)){ |
|
45 | 45 | return $this->extractToken($request); |
46 | 46 | } |
47 | 47 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | string $tokenID, |
58 | 58 | \DateTimeInterface $expiresAt = null |
59 | 59 | ): Response { |
60 | - if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) { |
|
60 | + if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID){ |
|
61 | 61 | return $response; |
62 | 62 | } |
63 | 63 | |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | { |
81 | 81 | $headerLine = $request->getHeaderLine($this->header); |
82 | 82 | |
83 | - if ($this->valueFormat !== '%s') { |
|
83 | + if ($this->valueFormat !== '%s'){ |
|
84 | 84 | [$token] = sscanf($headerLine, $this->valueFormat); |
85 | 85 | |
86 | - return $token !== null ? (string) $token : null; |
|
86 | + return $token !== null ? (string)$token : null; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $headerLine; |
@@ -41,7 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function fetchToken(Request $request): ?string |
43 | 43 | { |
44 | - if ($request->hasHeader($this->header)) { |
|
44 | + if ($request->hasHeader($this->header)) |
|
45 | + { |
|
45 | 46 | return $this->extractToken($request); |
46 | 47 | } |
47 | 48 | |
@@ -57,7 +58,8 @@ discard block |
||
57 | 58 | string $tokenID, |
58 | 59 | \DateTimeInterface $expiresAt = null |
59 | 60 | ): Response { |
60 | - if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) { |
|
61 | + if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) |
|
62 | + { |
|
61 | 63 | return $response; |
62 | 64 | } |
63 | 65 | |
@@ -80,7 +82,8 @@ discard block |
||
80 | 82 | { |
81 | 83 | $headerLine = $request->getHeaderLine($this->header); |
82 | 84 | |
83 | - if ($this->valueFormat !== '%s') { |
|
85 | + if ($this->valueFormat !== '%s') |
|
86 | + { |
|
84 | 87 | [$token] = sscanf($headerLine, $this->valueFormat); |
85 | 88 | |
86 | 89 | return $token !== null ? (string) $token : null; |