Total Complexity | 4 |
Total Lines | 59 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Retrieve the PDF's AWS S3 url. |
||
60 | * |
||
61 | * @return string|null |
||
62 | */ |
||
63 | public function url(): ?string |
||
66 | } |
||
67 | } |
||
68 |