Passed
Pull Request — master (#407)
by Kirill
05:31
created
src/Validation/src/Checker/StringChecker.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,8 @@
 block discarded – undo
88 88
      */
89 89
     public function range($value, int $min, int $max): bool
90 90
     {
91
-        if (!is_string($value)) {
91
+        if (!is_string($value))
92
+        {
92 93
             return false;
93 94
         }
94 95
 
Please login to merge, or discard this patch.
src/Framework/Bootloader/Storage/StorageConfig.php 1 patch
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -100,8 +100,10 @@  discard block
 block discarded – undo
100 100
      */
101 101
     private function bootStorages(array $config): void
102 102
     {
103
-        foreach ($config['buckets'] as $name => $bucket) {
104
-            if (!\is_string($name)) {
103
+        foreach ($config['buckets'] as $name => $bucket)
104
+        {
105
+            if (!\is_string($name))
106
+            {
105 107
                 throw new InvalidArgumentException(
106 108
                     \vsprintf('Storage bucket config key must be a string, but %s defined', [
107 109
                         \get_debug_type($name),
@@ -110,7 +112,8 @@  discard block
 block discarded – undo
110 112
             }
111 113
 
112 114
             $serverName = $bucket['server'] ?? null;
113
-            if (!\is_string($serverName)) {
115
+            if (!\is_string($serverName))
116
+            {
114 117
                 throw new InvalidArgumentException(
115 118
                     \vsprintf('Storage bucket `%s.server` config key required and must be a string, but %s defined', [
116 119
                         $name,
@@ -120,7 +123,8 @@  discard block
 block discarded – undo
120 123
             }
121 124
 
122 125
             $server = $config['servers'][$serverName] ?? null;
123
-            if (!\is_array($server)) {
126
+            if (!\is_array($server))
127
+            {
124 128
                 throw new InvalidArgumentException(
125 129
                     \vsprintf('Storage bucket `%s` relates to non-existing server `%s`', [
126 130
                         $name,
@@ -130,7 +134,8 @@  discard block
 block discarded – undo
130 134
             }
131 135
 
132 136
             $adapter = $server['adapter'] ?? null;
133
-            if (!\is_string($adapter)) {
137
+            if (!\is_string($adapter))
138
+            {
134 139
                 throw new InvalidArgumentException(
135 140
                     \vsprintf('Storage server `%s.adapter` config key required and must be a string, but %s defined', [
136 141
                         $serverName,
@@ -143,7 +148,8 @@  discard block
 block discarded – undo
143 148
 
144 149
             $this->adapters[$name] = $adapter;
145 150
 
146
-            if (isset($bucket['cdn'])) {
151
+            if (isset($bucket['cdn']))
152
+            {
147 153
                 $this->distributions[$name] = $bucket['cdn'];
148 154
             }
149 155
         }
@@ -157,7 +163,8 @@  discard block
 block discarded – undo
157 163
      */
158 164
     private function createAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter
159 165
     {
160
-        switch ($server['adapter']) {
166
+        switch ($server['adapter'])
167
+        {
161 168
             case 'local':
162 169
                 return $this->createLocalAdapter($serverName, $bucket, $server);
163 170
 
@@ -194,8 +201,10 @@  discard block
 block discarded – undo
194 201
 
195 202
         $bucket = $bucket['bucket'] ?? $server['bucket'];
196 203
 
197
-        if ($async) {
198
-            if (!\class_exists(AsyncAwsS3Adapter::class)) {
204
+        if ($async)
205
+        {
206
+            if (!\class_exists(AsyncAwsS3Adapter::class))
207
+            {
199 208
                 throw new InvalidArgumentException(
200 209
                     'Can not create async S3 client, please install "league/flysystem-async-aws-s3"'
201 210
                 );
@@ -207,7 +216,8 @@  discard block
 block discarded – undo
207 216
             );
208 217
         }
209 218
 
210
-        if (!\class_exists(AwsS3V3Adapter::class)) {
219
+        if (!\class_exists(AwsS3V3Adapter::class))
220
+        {
211 221
             throw new InvalidArgumentException(
212 222
                 'Can not create S3 client, please install "league/flysystem-aws-s3-v3"'
213 223
             );
@@ -227,7 +237,8 @@  discard block
 block discarded – undo
227 237
      */
228 238
     private function createLocalAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter
229 239
     {
230
-        if (!\is_string($server['directory'] ?? null)) {
240
+        if (!\is_string($server['directory'] ?? null))
241
+        {
231 242
             throw new InvalidArgumentException(
232 243
                 \vsprintf('Storage server `%s.directory` config key required and must be a string, but %s defined', [
233 244
                     $serverName,
@@ -262,7 +273,8 @@  discard block
 block discarded – undo
262 273
         $adapter = $server['adapter'];
263 274
         $isFilesystemAdapter = \is_subclass_of($adapter, FilesystemAdapter::class, true);
264 275
 
265
-        if (!$isFilesystemAdapter) {
276
+        if (!$isFilesystemAdapter)
277
+        {
266 278
             throw new InvalidArgumentException(
267 279
                 \vsprintf('Storage server `%s` must be a class string of %s, but `%s` defined', [
268 280
                     $serverName,
@@ -272,9 +284,12 @@  discard block
 block discarded – undo
272 284
             );
273 285
         }
274 286
 
275
-        try {
287
+        try
288
+        {
276 289
             return new $adapter(...\array_values($server['options'] ?? []));
277
-        } catch (\Throwable $e) {
290
+        }
291
+        catch (\Throwable $e)
292
+        {
278 293
             $message = 'An error occurred while server `%s` initializing: %s';
279 294
             throw new InvalidArgumentException(\sprintf($message, $serverName, $e->getMessage()), 0, $e);
280 295
         }
Please login to merge, or discard this patch.
src/Framework/Bootloader/Storage/StorageBootloader.php 1 patch
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,12 +31,14 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $app->bindInjector(StorageConfig::class, ConfiguratorInterface::class);
33 33
 
34
-        $app->bindSingleton(ManagerInterface::class, static function (StorageConfig $config, CdnInterface $cdn) {
34
+        $app->bindSingleton(ManagerInterface::class, static function (StorageConfig $config, CdnInterface $cdn)
35
+        {
35 36
             $manager = new Manager($config->getDefaultBucket());
36 37
 
37 38
             $distributions = $config->getDistributions();
38 39
 
39
-            foreach ($config->getAdapters() as $name => $adapter) {
40
+            foreach ($config->getAdapters() as $name => $adapter)
41
+            {
40 42
                 $resolver = isset($distributions[$name])
41 43
                     ? $cdn->resolver($distributions[$name])
42 44
                     : null;
@@ -47,15 +49,18 @@  discard block
 block discarded – undo
47 49
             return $manager;
48 50
         });
49 51
 
50
-        $app->bindSingleton(Manager::class, static function (ManagerInterface $manager) {
52
+        $app->bindSingleton(Manager::class, static function (ManagerInterface $manager)
53
+        {
51 54
             return $manager;
52 55
         });
53 56
 
54
-        $app->bindSingleton(StorageInterface::class, static function (ManagerInterface $manager) {
57
+        $app->bindSingleton(StorageInterface::class, static function (ManagerInterface $manager)
58
+        {
55 59
             return $manager->storage();
56 60
         });
57 61
 
58
-        $app->bindSingleton(Storage::class, static function (StorageInterface $storage) {
62
+        $app->bindSingleton(Storage::class, static function (StorageInterface $storage)
63
+        {
59 64
             return $storage;
60 65
         });
61 66
     }
Please login to merge, or discard this patch.
src/Framework/Bootloader/Distribution/DistributionBootloader.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -54,11 +54,13 @@  discard block
 block discarded – undo
54 54
      */
55 55
     private function registerResolver(Container $app): void
56 56
     {
57
-        $app->bindSingleton(ResolverInterface::class, static function (ManagerInterface $manager) {
57
+        $app->bindSingleton(ResolverInterface::class, static function (ManagerInterface $manager)
58
+        {
58 59
             return $manager->resolver();
59 60
         });
60 61
 
61
-        $app->bindSingleton(Resolver::class, static function (Container $app) {
62
+        $app->bindSingleton(Resolver::class, static function (Container $app)
63
+        {
62 64
             return $app->get(ResolverInterface::class);
63 65
         });
64 66
     }
@@ -68,21 +70,25 @@  discard block
 block discarded – undo
68 70
      */
69 71
     private function registerManager(Container $app): void
70 72
     {
71
-        $app->bindSingleton(ManagerInterface::class, static function (DistributionConfig $config) {
73
+        $app->bindSingleton(ManagerInterface::class, static function (DistributionConfig $config)
74
+        {
72 75
             $manager = new Manager($config->getDefaultDriver());
73 76
 
74
-            foreach ($config->getResolvers() as $name => $resolver) {
77
+            foreach ($config->getResolvers() as $name => $resolver)
78
+            {
75 79
                 $manager->add($name, $resolver);
76 80
             }
77 81
 
78 82
             return $manager;
79 83
         });
80 84
 
81
-        $app->bindSingleton(MutableManagerInterface::class, static function (Container $app) {
85
+        $app->bindSingleton(MutableManagerInterface::class, static function (Container $app)
86
+        {
82 87
             return $app->get(ManagerInterface::class);
83 88
         });
84 89
 
85
-        $app->bindSingleton(Manager::class, static function (Container $app) {
90
+        $app->bindSingleton(Manager::class, static function (Container $app)
91
+        {
86 92
             return $app->get(ManagerInterface::class);
87 93
         });
88 94
     }
Please login to merge, or discard this patch.
src/Framework/Bootloader/Distribution/DistributionConfig.php 1 patch
Braces   +51 added lines, -25 removed lines patch added patch discarded remove patch
@@ -71,8 +71,10 @@  discard block
 block discarded – undo
71 71
      */
72 72
     private function bootResolvers(array $config): void
73 73
     {
74
-        foreach ($config['resolvers'] ?? [] as $name => $child) {
75
-            if (!\is_string($name)) {
74
+        foreach ($config['resolvers'] ?? [] as $name => $child)
75
+        {
76
+            if (!\is_string($name))
77
+            {
76 78
                 throw new InvalidArgumentException(
77 79
                     \vsprintf('Distribution driver config key must be a string, but %s given', [
78 80
                         \get_debug_type($child),
@@ -80,7 +82,8 @@  discard block
 block discarded – undo
80 82
                 );
81 83
             }
82 84
 
83
-            if (!\is_array($child)) {
85
+            if (!\is_array($child))
86
+            {
84 87
                 throw new InvalidArgumentException(
85 88
                     \vsprintf('Distribution driver config `%s` must be an array, but %s given', [
86 89
                         $name,
@@ -100,9 +103,11 @@  discard block
 block discarded – undo
100 103
     {
101 104
         $default = $config['default'] ?? null;
102 105
 
103
-        if ($default !== null) {
106
+        if ($default !== null)
107
+        {
104 108
             // Validate config
105
-            if (!\is_string($default)) {
109
+            if (!\is_string($default))
110
+            {
106 111
                 throw new InvalidArgumentException(
107 112
                     \vsprintf('Distribution config default driver must be a string, but %s given', [
108 113
                         \get_debug_type($default),
@@ -121,13 +126,15 @@  discard block
 block discarded – undo
121 126
      */
122 127
     private function createResolver(string $name, array $config): ResolverInterface
123 128
     {
124
-        if (!isset($config['type']) || !\is_string($config['type'])) {
129
+        if (!isset($config['type']) || !\is_string($config['type']))
130
+        {
125 131
             throw $this->invalidConfigKey($name, 'type', 'string');
126 132
         }
127 133
 
128 134
         $type = $config['type'];
129 135
 
130
-        switch ($type) {
136
+        switch ($type)
137
+        {
131 138
             case 'static':
132 139
                 return $this->createStaticResolver($name, $config);
133 140
 
@@ -150,17 +157,22 @@  discard block
 block discarded – undo
150 157
      */
151 158
     private function createCustomResolver(string $type, string $name, array $config): ResolverInterface
152 159
     {
153
-        if (!\is_subclass_of($type, ResolverInterface::class, true)) {
160
+        if (!\is_subclass_of($type, ResolverInterface::class, true))
161
+        {
154 162
             throw $this->invalidConfigKey($name, 'type', ResolverInterface::class);
155 163
         }
156 164
 
157
-        if (isset($config['options']) && !\is_array($config['options'])) {
165
+        if (isset($config['options']) && !\is_array($config['options']))
166
+        {
158 167
             throw $this->invalidConfigKey($name, 'options', 'array');
159 168
         }
160 169
 
161
-        try {
170
+        try
171
+        {
162 172
             return new $type(...\array_values($config['options'] ?? []));
163
-        } catch (\Throwable $e) {
173
+        }
174
+        catch (\Throwable $e)
175
+        {
164 176
             $message = 'An error occurred while resolver `%s` initializing: %s';
165 177
             throw new InvalidArgumentException(\sprintf($message, $name, $e->getMessage()), 0, $e);
166 178
         }
@@ -174,32 +186,39 @@  discard block
 block discarded – undo
174 186
     private function createS3Resolver(string $name, array $config): ResolverInterface
175 187
     {
176 188
         // Required config options
177
-        if (!isset($config['region']) || !\is_string($config['region'])) {
189
+        if (!isset($config['region']) || !\is_string($config['region']))
190
+        {
178 191
             throw $this->invalidConfigKey($name, 'region', 'string');
179 192
         }
180 193
 
181
-        if (!isset($config['key']) || !\is_string($config['key'])) {
194
+        if (!isset($config['key']) || !\is_string($config['key']))
195
+        {
182 196
             throw $this->invalidConfigKey($name, 'key', 'string');
183 197
         }
184 198
 
185
-        if (!isset($config['secret']) || !\is_string($config['secret'])) {
199
+        if (!isset($config['secret']) || !\is_string($config['secret']))
200
+        {
186 201
             throw $this->invalidConfigKey($name, 'secret', 'string');
187 202
         }
188 203
 
189
-        if (!isset($config['bucket']) || !\is_string($config['bucket'])) {
204
+        if (!isset($config['bucket']) || !\is_string($config['bucket']))
205
+        {
190 206
             throw $this->invalidConfigKey($name, 'bucket', 'string');
191 207
         }
192 208
 
193 209
         // Optional config options
194
-        if (!\is_string($config['version'] ?? '')) {
210
+        if (!\is_string($config['version'] ?? ''))
211
+        {
195 212
             throw $this->invalidConfigKey($name, 'version', 'string or null');
196 213
         }
197 214
 
198
-        if (!\is_string($config['token'] ?? '')) {
215
+        if (!\is_string($config['token'] ?? ''))
216
+        {
199 217
             throw $this->invalidConfigKey($name, 'token', 'string or null');
200 218
         }
201 219
 
202
-        if (!\is_int($config['expires'] ?? 0)) {
220
+        if (!\is_int($config['expires'] ?? 0))
221
+        {
203 222
             throw $this->invalidConfigKey($name, 'expires', 'positive int (unix timestamp)');
204 223
         }
205 224
 
@@ -224,15 +243,18 @@  discard block
 block discarded – undo
224 243
      */
225 244
     private function createCloudFrontResolver(string $name, array $config): ResolverInterface
226 245
     {
227
-        if (!isset($config['key']) || !\is_string($config['key'])) {
246
+        if (!isset($config['key']) || !\is_string($config['key']))
247
+        {
228 248
             throw $this->invalidConfigKey($name, 'key', 'string');
229 249
         }
230 250
 
231
-        if (!isset($config['private']) || !\is_string($config['private'])) {
251
+        if (!isset($config['private']) || !\is_string($config['private']))
252
+        {
232 253
             throw $this->invalidConfigKey($name, 'private', 'string value or path to key file');
233 254
         }
234 255
 
235
-        if (!isset($config['domain']) || !\is_string($config['domain'])) {
256
+        if (!isset($config['domain']) || !\is_string($config['domain']))
257
+        {
236 258
             throw $this->invalidConfigKey($name, 'domain', 'string');
237 259
         }
238 260
 
@@ -250,7 +272,8 @@  discard block
 block discarded – undo
250 272
      */
251 273
     private function createStaticResolver(string $name, array $config): ResolverInterface
252 274
     {
253
-        if (!isset($config['uri']) || !\is_string($config['uri'])) {
275
+        if (!isset($config['uri']) || !\is_string($config['uri']))
276
+        {
254 277
             throw $this->invalidConfigKey($name, 'uri', 'string');
255 278
         }
256 279
 
@@ -265,16 +288,19 @@  discard block
 block discarded – undo
265 288
      */
266 289
     private function createUri(string $name, string $uri, array $config): UriInterface
267 290
     {
268
-        if (!\is_string($config['factory'] ?? '')) {
291
+        if (!\is_string($config['factory'] ?? ''))
292
+        {
269 293
             throw $this->invalidConfigKey($name, 'factory', 'string (PSR-7 uri factory implementation)');
270 294
         }
271 295
 
272
-        switch (true) {
296
+        switch (true)
297
+        {
273 298
             case isset($config['factory']):
274 299
                 /** @var UriFactoryInterface $factory */
275 300
                 $factory = new $config['factory']();
276 301
 
277
-                if (!$factory instanceof UriFactoryInterface) {
302
+                if (!$factory instanceof UriFactoryInterface)
303
+                {
278 304
                     $message = 'Distribution config driver `%s` should contain class that must be a valid PSR-7 ' .
279 305
                         'uri factory implementation, but `%s` given';
280 306
                     throw new InvalidArgumentException(\sprintf($message, $name, $config['factory']));
Please login to merge, or discard this patch.
src/Distribution/src/Manager.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,7 +65,8 @@  discard block
 block discarded – undo
65 65
     {
66 66
         $name = $name ?? $this->default;
67 67
 
68
-        if (!isset($this->resolvers[$name])) {
68
+        if (!isset($this->resolvers[$name]))
69
+        {
69 70
             throw new \InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name));
70 71
         }
71 72
 
@@ -77,7 +78,8 @@  discard block
 block discarded – undo
77 78
      */
78 79
     public function add(string $name, ResolverInterface $resolver, bool $overwrite = false): void
79 80
     {
80
-        if ($overwrite === false && isset($this->resolvers[$name])) {
81
+        if ($overwrite === false && isset($this->resolvers[$name]))
82
+        {
81 83
             throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name));
82 84
         }
83 85
 
Please login to merge, or discard this patch.
src/Distribution/src/Resolver/ExpirationAwareResolver.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,7 +113,8 @@
 block discarded – undo
113 113
      */
114 114
     private function resolveExpirationInterval($expiration): \DateInterval
115 115
     {
116
-        if ($expiration === null) {
116
+        if ($expiration === null)
117
+        {
117 118
             return $this->expiration;
118 119
         }
119 120
 
Please login to merge, or discard this patch.
src/Distribution/src/Resolver/CloudFrontResolver.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,8 @@
 block discarded – undo
78 78
      */
79 79
     protected function assertCloudFrontAvailable(): void
80 80
     {
81
-        if (\class_exists(UrlSigner::class)) {
81
+        if (\class_exists(UrlSigner::class))
82
+        {
82 83
             return;
83 84
         }
84 85
 
Please login to merge, or discard this patch.
src/Distribution/src/Internal/AmazonUriFactory.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@
 block discarded – undo
48 48
      */
49 49
     private function assertAvailable(): void
50 50
     {
51
-        if (\class_exists(Uri::class)) {
51
+        if (\class_exists(Uri::class))
52
+        {
52 53
             return;
53 54
         }
54 55
 
Please login to merge, or discard this patch.