ListCommand   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 66
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A toArgs() 0 3 1
A getPrefix() 0 3 1
A byPrefix() 0 5 1
A getName() 0 3 1
A getBucket() 0 3 1
A inBucket() 0 5 1
1
<?php
2
3
namespace diecoding\aws\s3\commands;
4
5
use Aws\ResultInterface;
6
use diecoding\aws\s3\base\commands\ExecutableCommand;
7
use diecoding\aws\s3\base\commands\traits\Async;
8
use diecoding\aws\s3\base\commands\traits\Options;
9
use diecoding\aws\s3\interfaces\commands\Asynchronous;
10
use diecoding\aws\s3\interfaces\commands\HasBucket;
11
use diecoding\aws\s3\interfaces\commands\PlainCommand;
12
use GuzzleHttp\Promise\PromiseInterface;
13
14
/**
15
 * Class ListCommand
16
 *
17
 * @method ResultInterface|PromiseInterface execute()
18
 *
19
 * @package diecoding\aws\s3\commands
20
 */
21
class ListCommand extends ExecutableCommand implements PlainCommand, HasBucket, Asynchronous
22
{
23
    use Async;
24
    use Options;
25
26
    /** @var array */
27
    protected $args = [];
28
29
    /**
30
     * @return string
31
     */
32
    public function getBucket(): string
33
    {
34
        return $this->args['Bucket'] ?? '';
35
    }
36
37
    /**
38
     * @param string $name
39
     *
40
     * @return $this
41
     */
42
    public function inBucket(string $name)
43
    {
44
        $this->args['Bucket'] = $name;
45
46
        return $this;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getPrefix(): string
53
    {
54
        return $this->args['Prefix'] ?? '';
55
    }
56
57
    /**
58
     * @param string $prefix
59
     *
60
     * @return $this
61
     */
62
    public function byPrefix(string $prefix)
63
    {
64
        $this->args['Prefix'] = $prefix;
65
66
        return $this;
67
    }
68
69
    /**
70
     * @internal used by the handlers
71
     *
72
     * @return string
73
     */
74
    public function getName(): string
75
    {
76
        return 'ListObjects';
77
    }
78
79
    /**
80
     * @internal used by the handlers
81
     *
82
     * @return array
83
     */
84
    public function toArgs(): array
85
    {
86
        return array_replace($this->options, $this->args);
87
    }
88
}
89