1 | <?php |
||
23 | class File |
||
24 | { |
||
25 | /** |
||
26 | * @var null|string |
||
27 | */ |
||
28 | private $filename = null; |
||
29 | |||
30 | /** |
||
31 | * File constructor. |
||
32 | * |
||
33 | * @param string $filename |
||
34 | */ |
||
35 | 14 | public function __construct(string $filename) |
|
39 | |||
40 | /** |
||
41 | * States whether the file actually exists on disk |
||
42 | * @return bool |
||
43 | */ |
||
44 | 7 | public function exists(): bool |
|
48 | |||
49 | /** |
||
50 | * States whether the file is readable |
||
51 | * @return bool |
||
52 | */ |
||
53 | 4 | public function isReadable(): bool |
|
57 | |||
58 | /** |
||
59 | * @return bool |
||
60 | */ |
||
61 | 5 | public function isWritable(): bool |
|
65 | |||
66 | /** |
||
67 | * Write content to the current file |
||
68 | * |
||
69 | * @param \NeedleProject\FileIo\Content\ContentInterface $content |
||
70 | * @return \NeedleProject\FileIo\File |
||
71 | * @throws \NeedleProject\FileIo\Exception\PermissionDeniedException |
||
72 | */ |
||
73 | 3 | public function write(ContentInterface $content): File |
|
81 | |||
82 | /** |
||
83 | * @return \NeedleProject\FileIo\Content\ContentInterface |
||
84 | * @throws \NeedleProject\FileIo\Exception\FileNotFoundException |
||
85 | * @throws \NeedleProject\FileIo\Exception\PermissionDeniedException |
||
86 | */ |
||
87 | 3 | public function getContent(): ContentInterface |
|
99 | |||
100 | /** |
||
101 | * Deletes the current file |
||
102 | */ |
||
103 | 2 | public function delete(): bool |
|
110 | } |
||
111 |