|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Spiral Framework package. |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
declare(strict_types=1); |
|
11
|
|
|
|
|
12
|
|
|
namespace Spiral\Storage\File; |
|
13
|
|
|
|
|
14
|
|
|
use JetBrains\PhpStorm\ExpectedValues; |
|
15
|
|
|
use Spiral\Storage\StorageInterface; |
|
16
|
|
|
use Spiral\Storage\Visibility; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @mixin ReadableInterface |
|
20
|
|
|
*/ |
|
21
|
|
|
trait ReadableTrait |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* {@see EntryInterface::getPathname()} |
|
25
|
|
|
*/ |
|
26
|
|
|
abstract public function getPathname(): string; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* {@see EntryInterface::getStorage()} |
|
30
|
|
|
*/ |
|
31
|
|
|
abstract public function getStorage(): StorageInterface; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritDoc} |
|
35
|
|
|
*/ |
|
36
|
|
|
public function exists(): bool |
|
37
|
|
|
{ |
|
38
|
|
|
$storage = $this->getStorage(); |
|
39
|
|
|
|
|
40
|
|
|
return $storage->exists($this->getPathname()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritDoc} |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getContents(): string |
|
47
|
|
|
{ |
|
48
|
|
|
$storage = $this->getStorage(); |
|
49
|
|
|
|
|
50
|
|
|
return $storage->getContents($this->getPathname()); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* {@inheritDoc} |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getStream() |
|
57
|
|
|
{ |
|
58
|
|
|
$storage = $this->getStorage(); |
|
59
|
|
|
|
|
60
|
|
|
return $storage->getStream($this->getPathname()); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* {@inheritDoc} |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getLastModified(): int |
|
67
|
|
|
{ |
|
68
|
|
|
$storage = $this->getStorage(); |
|
69
|
|
|
|
|
70
|
|
|
return $storage->getLastModified($this->getPathname()); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritDoc} |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getSize(): int |
|
77
|
|
|
{ |
|
78
|
|
|
$storage = $this->getStorage(); |
|
79
|
|
|
|
|
80
|
|
|
return $storage->getSize($this->getPathname()); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* {@inheritDoc} |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getMimeType(): string |
|
87
|
|
|
{ |
|
88
|
|
|
$storage = $this->getStorage(); |
|
89
|
|
|
|
|
90
|
|
|
return $storage->getMimeType($this->getPathname()); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* {@inheritDoc} |
|
95
|
|
|
*/ |
|
96
|
|
|
#[ExpectedValues(valuesFromClass: Visibility::class)] |
|
97
|
|
|
public function getVisibility(): string |
|
98
|
|
|
{ |
|
99
|
|
|
$storage = $this->getStorage(); |
|
100
|
|
|
|
|
101
|
|
|
return $storage->getVisibility($this->getPathname()); |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|