@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function handle(array $params = []): bool |
| 31 | 31 | { |
| 32 | - $bucketName = $params[ 'bucket' ]; |
|
| 32 | + $bucketName = $params['bucket']; |
|
| 33 | 33 | |
| 34 | 34 | try { |
| 35 | 35 | $accelerate = $this->client->getConn()->putBucketAccelerateConfiguration( |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ] |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - if (($accelerate instanceof ResultInterface) and $accelerate[ '@metadata' ][ 'statusCode' ] === 200) { |
|
| 44 | + if (($accelerate instanceof ResultInterface) and $accelerate['@metadata']['statusCode'] === 200) { |
|
| 45 | 45 | $this->commandHandlerLogger?->log($this, sprintf('Bucket \'%s\' was successfully set to transfer accelerated mode', $bucketName)); |
| 46 | 46 | |
| 47 | 47 | return true; |
@@ -64,6 +64,6 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function validateParams(array $params = []): bool |
| 66 | 66 | { |
| 67 | - return isset($params[ 'bucket' ]); |
|
| 67 | + return isset($params['bucket']); |
|
| 68 | 68 | } |
| 69 | 69 | } |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function handle(array $params = []): mixed |
| 32 | 32 | { |
| 33 | - $bucketName = $params[ 'bucket' ]; |
|
| 34 | - $keyName = $params[ 'key' ]; |
|
| 35 | - $version = (isset($params[ 'version' ])) ? $params[ 'version' ] : null; |
|
| 33 | + $bucketName = $params['bucket']; |
|
| 34 | + $keyName = $params['key']; |
|
| 35 | + $version = (isset($params['version'])) ? $params['version'] : null; |
|
| 36 | 36 | |
| 37 | 37 | if ($this->client->hasEncoder()) { |
| 38 | 38 | $keyName = $this->client->getEncoder()->encode($keyName); |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | public function validateParams(array $params = []): bool |
| 54 | 54 | { |
| 55 | 55 | return ( |
| 56 | - isset($params[ 'bucket' ]) and |
|
| 57 | - isset($params[ 'key' ]) |
|
| 56 | + isset($params['bucket']) and |
|
| 57 | + isset($params['key']) |
|
| 58 | 58 | ); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | ]; |
| 75 | 75 | |
| 76 | 76 | if (null != $version) { |
| 77 | - $config[ 'VersionId' ] = $version; |
|
| 77 | + $config['VersionId'] = $version; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $file = $this->client->getConn()->getObject($config); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | ]; |
| 101 | 101 | |
| 102 | 102 | if (null != $version) { |
| 103 | - $config[ 'VersionId' ] = $version; |
|
| 103 | + $config['VersionId'] = $version; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $file = $this->client->getConn()->getObject($config); |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function handle(array $params = []): bool |
| 28 | 28 | { |
| 29 | - $bucketName = $params[ 'bucket' ]; |
|
| 30 | - $keyName = $params[ 'key' ]; |
|
| 29 | + $bucketName = $params['bucket']; |
|
| 30 | + $keyName = $params['key']; |
|
| 31 | 31 | |
| 32 | 32 | if ($this->client->hasEncoder()) { |
| 33 | 33 | $keyName = $this->client->getEncoder()->encode($keyName); |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | public function validateParams(array $params = []): bool |
| 49 | 49 | { |
| 50 | 50 | return ( |
| 51 | - isset($params[ 'bucket' ]) and |
|
| 52 | - isset($params[ 'key' ]) |
|
| 51 | + isset($params['bucket']) and |
|
| 52 | + isset($params['key']) |
|
| 53 | 53 | ); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -29,35 +29,35 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function handle(array $params = []): array |
| 31 | 31 | { |
| 32 | - $bucketName = $params[ 'bucket' ]; |
|
| 32 | + $bucketName = $params['bucket']; |
|
| 33 | 33 | |
| 34 | 34 | try { |
| 35 | 35 | $config = [ |
| 36 | 36 | 'Bucket' => $bucketName, |
| 37 | 37 | ]; |
| 38 | 38 | |
| 39 | - if (isset($params[ 'prefix' ])) { |
|
| 39 | + if (isset($params['prefix'])) { |
|
| 40 | 40 | // add a final slash to prefix |
| 41 | - if (false === File::endsWith($params[ 'prefix' ], $this->client->getPrefixSeparator())) { |
|
| 42 | - $params[ 'prefix' ] .= $this->client->getPrefixSeparator(); |
|
| 41 | + if (false === File::endsWith($params['prefix'], $this->client->getPrefixSeparator())) { |
|
| 42 | + $params['prefix'] .= $this->client->getPrefixSeparator(); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $config[ 'Delimiter' ] = (isset($params[ 'delimiter' ])) ? $params[ 'delimiter' ] : $this->client->getPrefixSeparator(); |
|
| 46 | - $config[ 'Prefix' ] = $params[ 'prefix' ]; |
|
| 45 | + $config['Delimiter'] = (isset($params['delimiter'])) ? $params['delimiter'] : $this->client->getPrefixSeparator(); |
|
| 46 | + $config['Prefix'] = $params['prefix']; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // 1. If 'exclude-cache' is set, return records always from S3 |
| 50 | - if (isset($params[ 'exclude-cache' ]) and true === $params[ 'exclude-cache' ]) { |
|
| 51 | - return $this->returnItemsFromS3($bucketName, $config, (isset($params[ 'hydrate' ])) ? $params[ 'hydrate' ] : null); |
|
| 50 | + if (isset($params['exclude-cache']) and true === $params['exclude-cache']) { |
|
| 51 | + return $this->returnItemsFromS3($bucketName, $config, (isset($params['hydrate'])) ? $params['hydrate'] : null); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // 2. If the cache is set and there is a prefix, return records from cache |
| 55 | - if ($this->client->hasCache() and isset($config[ 'Prefix' ])) { |
|
| 56 | - return $this->returnItemsFromCache($bucketName, $config, (isset($params[ 'hydrate' ])) ? $params[ 'hydrate' ] : null); |
|
| 55 | + if ($this->client->hasCache() and isset($config['Prefix'])) { |
|
| 56 | + return $this->returnItemsFromCache($bucketName, $config, (isset($params['hydrate'])) ? $params['hydrate'] : null); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // 3. Otherwise, return records from S3 |
| 60 | - return $this->returnItemsFromS3($bucketName, $config, (isset($params[ 'hydrate' ])) ? $params[ 'hydrate' ] : null); |
|
| 60 | + return $this->returnItemsFromS3($bucketName, $config, (isset($params['hydrate'])) ? $params['hydrate'] : null); |
|
| 61 | 61 | } catch (S3Exception $e) { |
| 62 | 62 | $this->commandHandlerLogger?->logExceptionAndReturnFalse($e); |
| 63 | 63 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function validateParams(array $params = []): bool |
| 74 | 74 | { |
| 75 | - return (isset($params[ 'bucket' ])); |
|
| 75 | + return (isset($params['bucket'])); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | protected function returnItemsFromCache(string $bucketName, array $config, ?bool $hydrate = null): array |
| 86 | 86 | { |
| 87 | - $itemsFromCache = $this->client->getCache()->search($bucketName, $config[ 'Prefix' ]); |
|
| 87 | + $itemsFromCache = $this->client->getCache()->search($bucketName, $config['Prefix']); |
|
| 88 | 88 | |
| 89 | 89 | // no data was found, try to retrieve data from S3 |
| 90 | 90 | if (count($itemsFromCache) == 0) { |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | if (str_contains($key, '<VERSION_ID:')) { |
| 108 | 108 | $v = explode('<VERSION_ID:', $key); |
| 109 | - $version = str_replace('>', '', $v[ 1 ]); |
|
| 110 | - $key = $v[ 0 ]; |
|
| 109 | + $version = str_replace('>', '', $v[1]); |
|
| 110 | + $key = $v[0]; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | if ($this->client->hasEncoder()) { |
| 114 | 114 | $key = $this->client->getEncoder()->decode($key); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $items[ $originalKey ] = $this->client->getItem(['bucket' => $bucketName, 'key' => $key, 'version' => $version]); |
|
| 117 | + $items[$originalKey] = $this->client->getItem(['bucket' => $bucketName, 'key' => $key, 'version' => $version]); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | $this->commandHandlerLogger?->log($this, sprintf('Files of \'%s\' bucket were successfully obtained from CACHE', $bucketName)); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | foreach ($resultPaginator as $result) { |
| 142 | 142 | if (is_array($contents = $result->get('Contents'))) { |
| 143 | 143 | for ($i = 0; $i < count($contents); $i++) { |
| 144 | - $key = $contents[ $i ][ 'Key' ]; |
|
| 144 | + $key = $contents[$i]['Key']; |
|
| 145 | 145 | |
| 146 | 146 | if (false === File::endsWith($key, $this->client->getPrefixSeparator())) { |
| 147 | 147 | if ($this->client->hasEncoder()) { |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | if (null != $hydrate and true === $hydrate) { |
| 152 | - $items[ $key ] = $this->client->getItem(['bucket' => $bucketName, 'key' => $key]); |
|
| 152 | + $items[$key] = $this->client->getItem(['bucket' => $bucketName, 'key' => $key]); |
|
| 153 | 153 | } else { |
| 154 | 154 | $items[] = $key; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // send to cache, just to be sure that S3 is syncronized with cache |
| 158 | 158 | if ($this->client->hasCache()) { |
| 159 | - $this->client->getCache()->set($bucketName, $contents[ $i ][ 'Key' ], $this->client->getItem(['bucket' => $bucketName, 'key' => $key])); |
|
| 159 | + $this->client->getCache()->set($bucketName, $contents[$i]['Key'], $this->client->getItem(['bucket' => $bucketName, 'key' => $key])); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | $results = $this->client->getConn()->listObjectVersions($config); |
| 181 | 181 | $items = []; |
| 182 | 182 | |
| 183 | - if (false === isset($results[ 'Versions' ])) { |
|
| 183 | + if (false === isset($results['Versions'])) { |
|
| 184 | 184 | return $items; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - foreach ($results[ 'Versions' ] as $result) { |
|
| 188 | - $key = $result[ 'Key' ]; |
|
| 189 | - $version = $result[ 'VersionId' ]; |
|
| 187 | + foreach ($results['Versions'] as $result) { |
|
| 188 | + $key = $result['Key']; |
|
| 189 | + $version = $result['VersionId']; |
|
| 190 | 190 | |
| 191 | 191 | if (false === File::endsWith($key, $this->client->getPrefixSeparator())) { |
| 192 | 192 | if ($this->client->hasEncoder()) { |
@@ -196,14 +196,14 @@ discard block |
||
| 196 | 196 | $index = $key . '<VERSION_ID:' . $version . '>'; |
| 197 | 197 | |
| 198 | 198 | if (null != $hydrate and true === $hydrate) { |
| 199 | - $items[ $index ] = $this->client->getItem(['bucket' => $bucketName, 'key' => $key, 'version' => $version]); |
|
| 199 | + $items[$index] = $this->client->getItem(['bucket' => $bucketName, 'key' => $key, 'version' => $version]); |
|
| 200 | 200 | } else { |
| 201 | 201 | $items[] = $index; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // send to cache, just to be sure that S3 is syncronized with cache |
| 205 | 205 | if ($this->client->hasCache()) { |
| 206 | - $this->client->getCache()->set($bucketName, $result[ 'Key' ], $this->client->getItem(['bucket' => $bucketName, 'key' => $key, 'version' => $version]), $version); |
|
| 206 | + $this->client->getCache()->set($bucketName, $result['Key'], $this->client->getItem(['bucket' => $bucketName, 'key' => $key, 'version' => $version]), $version); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | } |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | try { |
| 32 | 32 | $ver = $this->client->getConn()->getBucketVersioning([ |
| 33 | - 'Bucket' => $params[ 'bucket' ] |
|
| 33 | + 'Bucket' => $params['bucket'] |
|
| 34 | 34 | ]); |
| 35 | 35 | |
| 36 | - return $ver[ 'Status' ] === 'Enabled'; |
|
| 36 | + return $ver['Status'] === 'Enabled'; |
|
| 37 | 37 | } catch (Exception $e) { |
| 38 | 38 | return $this->commandHandlerLogger?->logExceptionAndReturnFalse($e) ?? false; |
| 39 | 39 | } |
@@ -46,6 +46,6 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function validateParams(array $params = []): bool |
| 48 | 48 | { |
| 49 | - return isset($params[ 'bucket' ]); |
|
| 49 | + return isset($params['bucket']); |
|
| 50 | 50 | } |
| 51 | 51 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function handle(array $params = []): bool |
| 28 | 28 | { |
| 29 | - $bucketName = $params[ 'bucket' ]; |
|
| 29 | + $bucketName = $params['bucket']; |
|
| 30 | 30 | |
| 31 | 31 | return $this->client->getConn()->doesBucketExist($bucketName); |
| 32 | 32 | } |
@@ -38,6 +38,6 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function validateParams(array $params = []): bool |
| 40 | 40 | { |
| 41 | - return isset($params[ 'bucket' ]); |
|
| 41 | + return isset($params['bucket']); |
|
| 42 | 42 | } |
| 43 | 43 | } |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function handle(array $params = []): bool |
| 32 | 32 | { |
| 33 | - $bucketName = $params[ 'bucket' ]; |
|
| 34 | - $keyName = $params[ 'key' ]; |
|
| 33 | + $bucketName = $params['bucket']; |
|
| 34 | + $keyName = $params['key']; |
|
| 35 | 35 | |
| 36 | 36 | if ($this->client->hasEncoder()) { |
| 37 | 37 | $keyName = $this->client->getEncoder()->encode($keyName); |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | $download = $this->client->getConn()->getObject([ |
| 42 | 42 | 'Bucket' => $bucketName, |
| 43 | 43 | 'Key' => $keyName, |
| 44 | - 'SaveAs' => (isset($params[ 'save_as' ])) ? $params[ 'save_as' ] : $params[ 'key' ], |
|
| 44 | + 'SaveAs' => (isset($params['save_as'])) ? $params['save_as'] : $params['key'], |
|
| 45 | 45 | ]); |
| 46 | 46 | |
| 47 | - if (($download instanceof ResultInterface) and $download[ '@metadata' ][ 'statusCode' ] === 200) { |
|
| 47 | + if (($download instanceof ResultInterface) and $download['@metadata']['statusCode'] === 200) { |
|
| 48 | 48 | $this->commandHandlerLogger?->log($this, sprintf('\'%s\' was successfully downloaded from bucket \'%s\'', $keyName, $bucketName)); |
| 49 | 49 | |
| 50 | 50 | return true; |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | public function validateParams(array $params = []): bool |
| 69 | 69 | { |
| 70 | 70 | return ( |
| 71 | - isset($params[ 'bucket' ]) and |
|
| 72 | - isset($params[ 'key' ]) |
|
| 71 | + isset($params['bucket']) and |
|
| 72 | + isset($params['key']) |
|
| 73 | 73 | ); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function handle(array $params = []): bool |
| 32 | 32 | { |
| 33 | - $bucketName = $params[ 'bucket' ]; |
|
| 34 | - $keyName = $params[ 'key' ]; |
|
| 35 | - $version = (isset($params[ 'version' ])) ? $params[ 'version' ] : null; |
|
| 33 | + $bucketName = $params['bucket']; |
|
| 34 | + $keyName = $params['key']; |
|
| 35 | + $version = (isset($params['version'])) ? $params['version'] : null; |
|
| 36 | 36 | |
| 37 | 37 | if ($this->client->hasEncoder()) { |
| 38 | 38 | $keyName = $this->client->getEncoder()->encode($keyName); |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | ]; |
| 46 | 46 | |
| 47 | 47 | if (null != $version) { |
| 48 | - $config[ 'VersionId' ] = $version; |
|
| 48 | + $config['VersionId'] = $version; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $delete = $this->client->getConn()->deleteObject($config); |
| 52 | 52 | |
| 53 | - if (($delete instanceof ResultInterface) and $delete[ '@metadata' ][ 'statusCode' ] === 204) { |
|
| 53 | + if (($delete instanceof ResultInterface) and $delete['@metadata']['statusCode'] === 204) { |
|
| 54 | 54 | $this->commandHandlerLogger?->log($this, sprintf('File \'%s\' was successfully deleted from \'%s\' bucket', $keyName, $bucketName)); |
| 55 | 55 | |
| 56 | 56 | if ($this->client->hasCache()) { |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | public function validateParams(array $params = []): bool |
| 79 | 79 | { |
| 80 | 80 | return ( |
| 81 | - isset($params[ 'bucket' ]) and |
|
| 82 | - isset($params[ 'key' ]) |
|
| 81 | + isset($params['bucket']) and |
|
| 82 | + isset($params['key']) |
|
| 83 | 83 | ); |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function handle(array $params = []): bool |
| 32 | 32 | { |
| 33 | - $bucketName = $params[ 'bucket' ]; |
|
| 33 | + $bucketName = $params['bucket']; |
|
| 34 | 34 | |
| 35 | 35 | if (false === $this->client->hasBucket(['bucket' => $bucketName])) { |
| 36 | 36 | $this->commandHandlerLogger?->log($this, sprintf('Bucket \'%s\' does not exists', $bucketName), 'warning'); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $this->client->clearBucket(['bucket' => $bucketName]); |
| 43 | 43 | $delete = $this->client->getConn()->deleteBucket(['Bucket' => $bucketName]); |
| 44 | 44 | |
| 45 | - if (($delete instanceof ResultInterface) and $delete[ '@metadata' ][ 'statusCode' ] === 204) { |
|
| 45 | + if (($delete instanceof ResultInterface) and $delete['@metadata']['statusCode'] === 204) { |
|
| 46 | 46 | $this->commandHandlerLogger?->log($this, sprintf('Bucket \'%s\' was successfully deleted', $bucketName)); |
| 47 | 47 | |
| 48 | 48 | return true; |
@@ -65,6 +65,6 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function validateParams(array $params = []): bool |
| 67 | 67 | { |
| 68 | - return (isset($params[ 'bucket' ])); |
|
| 68 | + return (isset($params['bucket'])); |
|
| 69 | 69 | } |
| 70 | 70 | } |