Test Failed
Push — master ( 8ae349...d51c96 )
by Stephen
01:07 queued 11s
created

CloudStorage::enableStreaming()   A

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 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Sfneal\Helpers\Aws\S3\Utils;
4
5
use Illuminate\Contracts\Filesystem\Filesystem;
6
use Illuminate\Filesystem\FilesystemAdapter;
7
use Illuminate\Support\Facades\Storage;
8
use Sfneal\Helpers\Aws\S3\Utils\Traits\LocalFileDeletion;
9
use Sfneal\Helpers\Aws\S3\Utils\Traits\UploadStreaming;
10
11
class CloudStorage
12
{
13
    use LocalFileDeletion;
14
    use UploadStreaming;
15
16
    /**
17
     * @var string AWS S3 file key
18
     */
19
    protected $s3Key;
20
21
    /**
22
     * @var string Storage S3 cloud disk name
23
     */
24
    protected $disk;
25
26
    /**
27
     * S3 constructor.
28
     *
29
     * @param string $s3Key
30
     */
31
    public function __construct(string $s3Key)
32
    {
33
        $this->s3Key = $s3Key;
34
        $this->disk = config('filesystem.cloud', 's3');
35
    }
36
37
    /**
38
     * Retrieve the S3 key (useful in conjunctions with `autocompletePath()` method).
39
     *
40
     * @return string
41
     */
42
    public function getKey(): string
43
    {
44
        return $this->s3Key;
45
    }
46
47
    /**
48
     * Set the filesystem disk.
49
     *
50
     * @param string $disk
51
     * @return $this
52
     */
53
    public function setDisk(string $disk): self
54
    {
55
        $this->disk = $disk;
56
57
        return $this;
58
    }
59
60
    /**
61
     * Retrieve a Filesystem instance for the specified disk.
62
     *
63
     * @return Filesystem|FilesystemAdapter
64
     */
65
    protected function storageDisk(): FilesystemAdapter
66
    {
67
        return Storage::disk($this->disk);
68
    }
69
}
70