PutCommand::withAcl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
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\HasAcl;
11
use diecoding\aws\s3\interfaces\commands\HasBucket;
12
use diecoding\aws\s3\interfaces\commands\PlainCommand;
13
use GuzzleHttp\Promise\PromiseInterface;
14
15
/**
16
 * Class PutCommand
17
 *
18
 * @method ResultInterface|PromiseInterface execute()
19
 *
20
 * @package diecoding\aws\s3\commands
21
 */
22
class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, HasAcl, Asynchronous
23
{
24
    use Async;
25
    use Options;
26
27
    /** @var array */
28
    protected $args = [];
29
30
    /**
31
     * @return string
32
     */
33
    public function getBucket(): string
34
    {
35
        return $this->args['Bucket'] ?? '';
36
    }
37
38
    /**
39
     * @param string $name
40
     *
41
     * @return $this
42
     */
43
    public function inBucket(string $name)
44
    {
45
        $this->args['Bucket'] = $name;
46
47
        return $this;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getFilename(): string
54
    {
55
        return $this->args['Key'] ?? '';
56
    }
57
58
    /**
59
     * @param string $filename
60
     *
61
     * @return $this
62
     */
63
    public function withFilename(string $filename)
64
    {
65
        $this->args['Key'] = $filename;
66
67
        return $this;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getAcl(): string
74
    {
75
        return $this->args['ACL'] ?? '';
76
    }
77
78
    /**
79
     * @param string $acl
80
     *
81
     * @return $this
82
     */
83
    public function withAcl(string $acl)
84
    {
85
        $this->args['ACL'] = $acl;
86
87
        return $this;
88
    }
89
90
    /**
91
     * @return mixed
92
     */
93
    public function getBody()
94
    {
95
        return $this->args['Body'] ?? null;
96
    }
97
98
    /**
99
     * @param mixed $body
100
     *
101
     * @return $this
102
     */
103
    public function withBody($body)
104
    {
105
        $this->args['Body'] = $body;
106
107
        return $this;
108
    }
109
110
    /**
111
     * @return array
112
     */
113
    public function getMetadata(): array
114
    {
115
        return $this->args['Metadata'] ?? [];
116
    }
117
118
    /**
119
     * @param array $metadata
120
     *
121
     * @return $this
122
     */
123
    public function withMetadata(array $metadata)
124
    {
125
        $this->args['Metadata'] = $metadata;
126
127
        return $this;
128
    }
129
130
    /**
131
     * @return string
132
     */
133
    public function getContentType(): string
134
    {
135
        return $this->args['ContentType'] ?? '';
136
    }
137
138
    /**
139
     * @param string $contentType
140
     *
141
     * @return $this
142
     */
143
    public function withContentType(string $contentType)
144
    {
145
        $this->args['ContentType'] = $contentType;
146
147
        return $this;
148
    }
149
150
    /**
151
     * @return mixed
152
     */
153
    public function getExpiration()
154
    {
155
        return $this->args['Expires'] ?? null;
156
    }
157
158
    /**
159
     * @param mixed $expires
160
     *
161
     * @return $this
162
     */
163
    public function withExpiration($expires)
164
    {
165
        $this->args['Expires'] = $expires;
166
167
        return $this;
168
    }
169
170
    /**
171
     * @internal used by the handlers
172
     *
173
     * @return string
174
     */
175
    public function getName(): string
176
    {
177
        return 'PutObject';
178
    }
179
180
    /**
181
     * @internal used by the handlers
182
     *
183
     * @return array
184
     */
185
    public function toArgs(): array
186
    {
187
        return array_replace($this->options, $this->args);
188
    }
189
}
190