Passed
Pull Request — master (#33)
by Cesar
05:13
created

DownloadFileAction::disk()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace MagicLink\Actions;
4
5
use Illuminate\Support\Facades\Storage;
6
7
class DownloadFileAction implements ActionInterface
8
{
9
    protected $path;
10
11
    protected $name;
12
13
    protected $headers;
14
15
    protected $disk;
16
17
    /**
18
     * Constructor to action.
19
     *
20
     * @param  string  $path
21
     * @param  string|null  $name
22
     * @param  array  $headers
23
     * @return void
24
     */
25
    public function __construct(string $path, ?string $name = null, array $headers = [])
26
    {
27
        $this->path = $path;
28
        $this->name = $name;
29
        $this->headers = $headers;
30
    }
31
32
    public function disk(?string $disk): self
33
    {
34
        $this->disk = $disk;
35
36
        return $this;
37
    }
38
39
    /**
40
     * Execute Action.
41
     */
42
    public function run()
43
    {
44
        return Storage::disk($this->disk)->download($this->path, $this->name, $this->headers);
45
    }
46
}
47