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