Conditions | 6 |
Paths | 7 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 6.0106 |
Changes | 0 |
1 | <?php |
||
29 | 2 | public function handle($params = []) |
|
30 | { |
||
31 | 2 | $bucketName = $params['bucket']; |
|
32 | 2 | $keyName = $params['key']; |
|
33 | |||
34 | 2 | $fileInfo = File::getPathInfo($keyName); |
|
35 | 2 | $prefix = $fileInfo['dirname'] . $this->client->getPrefixSeparator(); |
|
36 | |||
37 | 2 | $results = $this->client->getConn()->listObjectVersions([ |
|
38 | 2 | 'Bucket' => $bucketName, |
|
39 | 2 | 'Prefix' => $prefix |
|
40 | ]); |
||
41 | |||
42 | 2 | if (false === isset($results['Versions'])) { |
|
43 | return null; |
||
44 | } |
||
45 | |||
46 | 2 | if ($this->client->hasEncoder()) { |
|
47 | 2 | $keyName = $this->client->getEncoder()->encode($keyName); |
|
48 | } |
||
49 | |||
50 | 2 | foreach ($results['Versions'] as $result) { |
|
51 | 2 | if (true === $result['IsLatest'] and $keyName === $result['Key']) { |
|
52 | 2 | return $result['VersionId']; |
|
53 | } |
||
70 |