Passed
Push — master ( 9b150b...d96454 )
by Kirill
07:23 queued 13s
created
src/Framework/Bootloader/Storage/StorageConfig.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Framework/Bootloader/Storage/StorageBootloader.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 
40 40
         $app->bindInjector(StorageConfig::class, ConfiguratorInterface::class);
41 41
 
42
-        $app->bindSingleton(StorageInterface::class, static function (StorageConfig $config, Container $app) {
42
+        $app->bindSingleton(StorageInterface::class, static function (StorageConfig $config, Container $app){
43 43
             $manager = new Storage($config->getDefaultBucket());
44 44
 
45 45
             $distributions = $config->getDistributions();
46 46
 
47
-            foreach ($config->getAdapters() as $name => $adapter) {
47
+            foreach ($config->getAdapters() as $name => $adapter){
48 48
                 $resolver = null;
49 49
 
50
-                if (isset($distributions[$name])) {
51
-                    try {
50
+                if (isset($distributions[$name])){
51
+                    try{
52 52
                         $cdn = $app->make(CdnInterface::class);
53
-                    } catch (NotFoundException $e) {
53
+                    }catch (NotFoundException $e){
54 54
                         $message = 'Unable to create distribution for bucket "%s". '
55 55
                             . 'Please make sure that bootloader %s is added in your application';
56 56
                         $message = \sprintf($message, $name, DistributionBootloader::class);
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
             return $manager;
68 68
         });
69 69
 
70
-        $app->bindSingleton(Storage::class, static function (StorageInterface $manager) {
70
+        $app->bindSingleton(Storage::class, static function (StorageInterface $manager){
71 71
             return $manager;
72 72
         });
73 73
 
74
-        $app->bindSingleton(BucketInterface::class, static function (StorageInterface $manager) {
74
+        $app->bindSingleton(BucketInterface::class, static function (StorageInterface $manager){
75 75
             return $manager->bucket();
76 76
         });
77 77
 
78
-        $app->bindSingleton(Bucket::class, static function (BucketInterface $storage) {
78
+        $app->bindSingleton(Bucket::class, static function (BucketInterface $storage){
79 79
             return $storage;
80 80
         });
81 81
     }
Please login to merge, or discard this patch.