| Total Complexity | 3 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class IsBucketVersioned extends CommandHandler |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Check if is enabled versioning for a bucket. |
||
| 21 | * For a complete reference: |
||
| 22 | * https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-versioning.html?highlight=versioning%20bucket |
||
| 23 | * |
||
| 24 | * @param array $params |
||
| 25 | * |
||
| 26 | * @return bool |
||
| 27 | * @throws Exception |
||
| 28 | */ |
||
| 29 | 18 | public function handle(array $params = []): mixed |
|
| 30 | { |
||
| 31 | try { |
||
| 32 | 18 | $ver = $this->client->getConn()->getBucketVersioning([ |
|
| 33 | 18 | 'Bucket' => $params[ 'bucket' ] |
|
| 34 | 18 | ]); |
|
| 35 | |||
| 36 | 17 | return $ver[ 'Status' ] === 'Enabled'; |
|
| 37 | 1 | } catch (Exception $e) { |
|
| 38 | 1 | return $this->commandHandlerLogger?->logExceptionAndReturnFalse($e) ?? false; |
|
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param array $params |
||
| 44 | * |
||
| 45 | * @return bool |
||
| 46 | */ |
||
| 47 | 18 | public function validateParams(array $params = []): bool |
|
| 50 | } |
||
| 51 | } |
||
| 52 |