RestoreCommand   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 105
rs 10
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A toArgs() 0 3 1
A withLifetime() 0 5 1
A getFilename() 0 3 1
A getVersionId() 0 3 1
A getLifetime() 0 3 1
A withVersionId() 0 5 1
A getName() 0 3 1
A inBucket() 0 5 1
A getBucket() 0 3 1
A byFilename() 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\interfaces\commands\Asynchronous;
9
use diecoding\aws\s3\interfaces\commands\HasBucket;
10
use diecoding\aws\s3\interfaces\commands\PlainCommand;
11
use GuzzleHttp\Promise\PromiseInterface;
12
13
/**
14
 * Class RestoreCommand
15
 *
16
 * @method ResultInterface|PromiseInterface execute()
17
 *
18
 * @package diecoding\aws\s3\commands
19
 */
20
class RestoreCommand extends ExecutableCommand implements PlainCommand, HasBucket, Asynchronous
21
{
22
    use Async;
23
24
    /** @var array */
25
    protected $args = [];
26
27
    /**
28
     * @return string
29
     */
30
    public function getBucket(): string
31
    {
32
        return $this->args['Bucket'] ?? '';
33
    }
34
35
    /**
36
     * @param string $name
37
     *
38
     * @return $this
39
     */
40
    public function inBucket(string $name)
41
    {
42
        $this->args['Bucket'] = $name;
43
44
        return $this;
45
    }
46
47
    /**
48
     * @return string
49
     */
50
    public function getFilename(): string
51
    {
52
        return $this->args['Key'] ?? '';
53
    }
54
55
    /**
56
     * @param string $filename
57
     *
58
     * @return $this
59
     */
60
    public function byFilename(string $filename)
61
    {
62
        $this->args['Key'] = $filename;
63
64
        return $this;
65
    }
66
67
    /**
68
     * @return int lifetime of the active copy in days
69
     */
70
    public function getLifetime(): int
71
    {
72
        return $this->args['Days'] ?? 0;
73
    }
74
75
    /**
76
     * @param int $days lifetime of the active copy in days
77
     *
78
     * @return $this
79
     */
80
    public function withLifetime(int $days)
81
    {
82
        $this->args['Days'] = $days;
83
84
        return $this;
85
    }
86
87
    /**
88
     * @return string
89
     */
90
    public function getVersionId(): string
91
    {
92
        return $this->args['VersionId'] ?? '';
93
    }
94
95
    /**
96
     * @param string $versionId
97
     *
98
     * @return $this
99
     */
100
    public function withVersionId(string $versionId)
101
    {
102
        $this->args['VersionId'] = $versionId;
103
104
        return $this;
105
    }
106
107
    /**
108
     * @internal used by the handlers
109
     *
110
     * @return string
111
     */
112
    public function getName(): string
113
    {
114
        return 'RestoreObject';
115
    }
116
117
    /**
118
     * @internal used by the handlers
119
     *
120
     * @return array
121
     */
122
    public function toArgs(): array
123
    {
124
        return $this->args;
125
    }
126
}
127