Total Complexity | 4 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
8 | trait HasChunkFolder |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * Temporary chunk folder |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected string $chunksFolder; |
||
17 | |||
18 | /** |
||
19 | * The callback used to store file. |
||
20 | * |
||
21 | * @var callable |
||
22 | */ |
||
23 | public ?\Closure $storeFileCallback = null; |
||
24 | |||
25 | /** |
||
26 | * Set chunk folder |
||
27 | * |
||
28 | * @param string $chunksFolder |
||
29 | * |
||
30 | * @return $this |
||
31 | */ |
||
32 | 1 | public function chunksFolder(string $chunksFolder) |
|
33 | { |
||
34 | 1 | $this->chunksFolder = $chunksFolder; |
|
35 | |||
36 | 1 | return $this; |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * Get chunk folder |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | 3 | public function getChunksFolder(): string |
|
45 | { |
||
46 | 3 | return $this->chunksFolder; |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * Specify the callback that should be used to save file. |
||
51 | * |
||
52 | * @param callable $storeFileCallback |
||
53 | * |
||
54 | * @return $this |
||
55 | */ |
||
56 | 13 | public function store(callable $storeFileCallback) |
|
57 | { |
||
58 | 13 | $this->storeFileCallback = $storeFileCallback; |
|
59 | |||
60 | 13 | return $this; |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * Store file |
||
65 | * |
||
66 | * @param NovaRequest $request |
||
67 | * @param $filePath |
||
68 | * |
||
69 | * @return string|null |
||
70 | */ |
||
71 | 2 | public function storeFile(NovaRequest $request, $filePath): ?string |
|
74 | } |
||
75 | } |
||
76 |