UploadCommand::getMupThreshold()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
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\interfaces\commands\Asynchronous;
9
use diecoding\aws\s3\interfaces\commands\HasAcl;
10
use diecoding\aws\s3\interfaces\commands\HasBucket;
11
use GuzzleHttp\Promise\PromiseInterface;
12
13
/**
14
 * Class UploadCommand
15
 *
16
 * @method ResultInterface|PromiseInterface execute()
17
 *
18
 * @package diecoding\aws\s3\commands
19
 */
20
class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asynchronous
21
{
22
    use Async;
23
24
    /** @var string */
25
    protected $bucket;
26
27
    /** @var string */
28
    protected $acl;
29
30
    /** @var mixed */
31
    protected $source;
32
33
    /** @var string */
34
    protected $filename;
35
36
    /** @var array */
37
    protected $options = [];
38
39
    /**
40
     * @return string
41
     */
42
    public function getBucket(): string
43
    {
44
        return (string)$this->bucket;
45
    }
46
47
    /**
48
     * @param string $name
49
     *
50
     * @return $this
51
     */
52
    public function inBucket(string $name)
53
    {
54
        $this->bucket = $name;
55
56
        return $this;
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getAcl(): string
63
    {
64
        return (string)$this->acl;
65
    }
66
67
    /**
68
     * @param string $acl
69
     *
70
     * @return $this
71
     */
72
    public function withAcl(string $acl)
73
    {
74
        $this->acl = $acl;
75
76
        return $this;
77
    }
78
79
    /**
80
     * @return mixed
81
     */
82
    public function getSource()
83
    {
84
        return $this->source;
85
    }
86
87
    /**
88
     * @param mixed $source
89
     *
90
     * @return $this
91
     */
92
    public function withSource($source)
93
    {
94
        $this->source = $source;
95
96
        return $this;
97
    }
98
99
    /**
100
     * @return string
101
     */
102
    public function getFilename(): string
103
    {
104
        return (string)$this->filename;
105
    }
106
107
    /**
108
     * @param string $filename
109
     *
110
     * @return $this
111
     */
112
    public function withFilename(string $filename)
113
    {
114
        $this->filename = $filename;
115
116
        return $this;
117
    }
118
119
    /**
120
     * @return int
121
     */
122
    public function getPartSize(): int
123
    {
124
        return $this->options['part_size'] ?? 0;
125
    }
126
127
    /**
128
     * @param int $partSize
129
     *
130
     * @return $this
131
     */
132
    public function withPartSize(int $partSize)
133
    {
134
        $this->options['part_size'] = $partSize;
135
136
        return $this;
137
    }
138
139
    /**
140
     * @return int
141
     */
142
    public function getConcurrency(): int
143
    {
144
        return $this->options['concurrency'] ?? 0;
145
    }
146
147
    /**
148
     * @param int $concurrency
149
     *
150
     * @return $this
151
     */
152
    public function withConcurrency(int $concurrency)
153
    {
154
        $this->options['concurrency'] = $concurrency;
155
156
        return $this;
157
    }
158
159
    /**
160
     * @return int
161
     */
162
    public function getMupThreshold(): int
163
    {
164
        return $this->options['mup_threshold'] ?? 0;
165
    }
166
167
    /**
168
     * @param int $mupThreshold
169
     *
170
     * @return $this
171
     */
172
    public function withMupThreshold(int $mupThreshold)
173
    {
174
        $this->options['mup_threshold'] = $mupThreshold;
175
176
        return $this;
177
    }
178
179
    /**
180
     * @return string
181
     */
182
    public function getContentType(): string
183
    {
184
        return $this->getParam('ContentType', '');
185
    }
186
187
    /**
188
     * @param string $contentType
189
     *
190
     * @return $this
191
     */
192
    public function withContentType(string $contentType)
193
    {
194
        return $this->withParam('ContentType', $contentType);
195
    }
196
197
    /**
198
     * @return string
199
     */
200
    public function getContentDisposition(): string
201
    {
202
        return $this->getParam('ContentDisposition', '');
203
    }
204
205
    /**
206
     * @param string $contentDisposition
207
     *
208
     * @return $this
209
     */
210
    public function withContentDisposition(string $contentDisposition)
211
    {
212
        return $this->withParam('ContentDisposition', $contentDisposition);
213
    }
214
215
    /**
216
     * @param string $name
217
     * @param mixed  $default
218
     *
219
     * @return mixed
220
     */
221
    public function getParam(string $name, $default = null)
222
    {
223
        return $this->options['params'][$name] ?? $default;
224
    }
225
226
    /**
227
     * @param string $name
228
     * @param mixed  $value
229
     *
230
     * @return $this
231
     */
232
    public function withParam(string $name, $value)
233
    {
234
        $this->options['params'][$name] = $value;
235
236
        return $this;
237
    }
238
239
    /**
240
     * @param callable $beforeUpload
241
     *
242
     * @return $this
243
     */
244
    public function beforeUpload(callable $beforeUpload)
245
    {
246
        $this->options['before_upload'] = $beforeUpload;
247
248
        return $this;
249
    }
250
251
    /**
252
     * @internal used by the handlers
253
     *
254
     * @return array
255
     */
256
    public function getOptions(): array
257
    {
258
        return $this->options;
259
    }
260
}
261