| 1 | <?php |
||
| 9 | class SingleLocalFile implements Adapter |
||
| 10 | { |
||
| 11 | private string |
||
|
|
|||
| 12 | $filename; |
||
| 13 | private Adapter |
||
| 14 | $adapter; |
||
| 15 | |||
| 16 | 29 | public function __construct(string $filename, Adapter $adapter) |
|
| 17 | { |
||
| 18 | 29 | $this->filename = $filename; |
|
| 19 | 29 | $this->adapter = $adapter; |
|
| 20 | 29 | } |
|
| 21 | |||
| 22 | 8 | public function read($key) |
|
| 23 | { |
||
| 24 | 8 | if(! $this->exists($key)) |
|
| 25 | { |
||
| 26 | 7 | return false; |
|
| 27 | } |
||
| 28 | |||
| 29 | 1 | return $this->adapter->read($key); |
|
| 30 | } |
||
| 31 | |||
| 32 | 2 | public function write($key, $content) |
|
| 33 | { |
||
| 34 | 2 | return $this->adapter->write($key, $content); |
|
| 35 | } |
||
| 36 | |||
| 37 | 15 | public function exists($key): bool |
|
| 38 | { |
||
| 39 | 15 | return $key === $this->filename; |
|
| 40 | } |
||
| 41 | |||
| 42 | 1 | public function keys() |
|
| 43 | { |
||
| 44 | 1 | return [$this->filename]; |
|
| 45 | } |
||
| 46 | |||
| 47 | 1 | public function mtime($key) |
|
| 48 | { |
||
| 49 | 1 | if(! $this->exists($key)) |
|
| 50 | { |
||
| 51 | 1 | return false; |
|
| 52 | } |
||
| 53 | |||
| 54 | 1 | return $this->adapter->mtime($key); |
|
| 55 | } |
||
| 56 | |||
| 57 | 6 | public function delete($key) |
|
| 58 | { |
||
| 59 | 6 | throw new \RuntimeException('Not implemented yet : ' . __METHOD__); |
|
| 60 | } |
||
| 61 | |||
| 62 | 1 | public function rename($sourceKey, $targetKey) |
|
| 63 | { |
||
| 64 | 1 | throw new \RuntimeException('Not implemented yet : ' . __METHOD__); |
|
| 65 | } |
||
| 66 | |||
| 67 | 6 | public function isDirectory($key): bool |
|
| 68 | { |
||
| 69 | 6 | return false; |
|
| 70 | } |
||
| 71 | } |
||
| 72 |