s3FileUrlTemp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
use Illuminate\Support\Facades\Storage;
4
use Sfneal\Helpers\Aws\S3\StorageS3;
5
6
/**
7
 * Return either an S3 file url.
8
 *
9
 * @param string $path
10
 * @return string
11
 */
12
function s3FileURL(string $path): string
13
{
14
    return StorageS3::key($path)->url();
15
}
16
17
/**
18
 * Return a temporary S3 file url.
19
 *
20
 * @param string $path
21
 * @param DateTimeInterface|null $expiration
22
 * @return string
23
 */
24
function s3FileUrlTemp(string $path, DateTimeInterface $expiration = null): string
25
{
26
    return StorageS3::key($path)->urlTemp($expiration);
27
}
28
29
/**
30
 * Determine if an S3 file exists.
31
 *
32
 * @param string $s3_key
33
 * @return bool
34
 */
35
function s3Exists(string $s3_key): bool
36
{
37
    return Storage::disk(config('filesystem.cloud', 's3'))->exists($s3_key);
38
}
39