-
Notifications
You must be signed in to change notification settings - Fork 176
/
FlysystemFile.php
56 lines (45 loc) · 1.15 KB
/
FlysystemFile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
namespace Oneup\UploaderBundle\Uploader\File;
use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator;
class FlysystemFile implements FileInterface
{
public function __construct(private string $pathname, private FilesystemOperator $filesystem)
{
}
/**
* @throws FilesystemException
*/
public function getSize(): int|false
{
return $this->filesystem->fileSize($this->pathname);
}
public function getPathname(): string
{
return $this->pathname;
}
public function getPath(): string
{
return pathinfo($this->pathname, \PATHINFO_DIRNAME);
}
/**
* @throws FilesystemException
*/
public function getMimeType(): ?string
{
return $this->filesystem->mimeType($this->pathname);
}
public function getBasename(): string
{
return basename($this->pathname);
}
public function getExtension(): string
{
return pathinfo($this->pathname, \PATHINFO_EXTENSION);
}
public function getFilesystem(): FilesystemOperator
{
return $this->filesystem;
}
}