GetPresignedUrlCommand   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 76
rs 10
wmc 7

7 Methods

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