Passed
Push — master ( c67edb...a841dd )
by Stephen
01:37 queued 11s
created

Exporter::upload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Sfneal\ViewExport\Support;
4
5
use Sfneal\Helpers\Aws\S3\S3;
6
7
abstract class Exporter
8
{
9
    /**
10
     * @var string|null AWS S3 file path
11
     */
12
    protected $path;
13
14
    /**
15
     * @var string|null AWS S3 file URL
16
     */
17
    protected $url;
18
19
    /**
20
     * @var string|null
21
     */
22
    protected $output;
23
24
    /**
25
     * Upload a rendered PDF to an AWS S3 file store.
26
     *
27
     * @param string $path
28
     * @return $this
29
     */
30
    public function upload(string $path): self
31
    {
32
        $this->path = $path;
33
        $this->url = (new S3($path))->upload_raw($this->output());
34
35
        return $this;
36
    }
37
38
    /**
39
     * Retrieve the PDF's output.
40
     *
41
     * @return string
42
     */
43
    public function output(): string
44
    {
45
        return $this->output;
46
    }
47
48
    /**
49
     * Retrieve the PDF's AWS S3 path.
50
     *
51
     * @return string|null
52
     */
53
    public function path(): ?string
54
    {
55
        return $this->path;
56
    }
57
58
    /**
59
     * Retrieve the PDF's AWS S3 url.
60
     *
61
     * @return string|null
62
     */
63
    public function url(): ?string
64
    {
65
        return $this->url;
66
    }
67
}
68