Total Complexity | 6 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
16 | class HasItem extends CommandHandler |
||
17 | { |
||
18 | /** |
||
19 | * Check if a item already exists. |
||
20 | * For a complete reference: |
||
21 | * https://docs.aws.amazon.com/cli/latest/reference/s3api/head-object.html |
||
22 | * |
||
23 | * @param array $params |
||
24 | * |
||
25 | * @return bool |
||
26 | */ |
||
27 | 5 | public function handle($params = []) |
|
28 | { |
||
29 | 5 | $bucketName = $params['bucket']; |
|
30 | 5 | $keyName = $params['key']; |
|
31 | |||
32 | 5 | if ($this->client->hasEncoder()) { |
|
33 | 4 | $keyName = $this->client->getEncoder()->encode($keyName); |
|
34 | } |
||
35 | |||
36 | 5 | if ($this->client->hasCache() and $this->client->getCache()->has($bucketName, $keyName)) { |
|
37 | 3 | return true; |
|
38 | } |
||
39 | |||
40 | 2 | return $this->client->getConn()->doesObjectExist($bucketName, $keyName); |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * @param array $params |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | 5 | public function validateParams($params = []) |
|
53 | ); |
||
54 | } |
||
56 |