1 | <?php |
||
15 | class File implements FileInterface |
||
16 | { |
||
17 | const OVERWRITE_ALL = 0; |
||
18 | const OVERWRITE_NONE = 1; |
||
19 | const OVERWRITE_OLDER = 2; |
||
20 | |||
21 | /** |
||
22 | * Path to file |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $path; |
||
26 | |||
27 | /** |
||
28 | * File constructor. |
||
29 | * |
||
30 | * @param string $path Path to file. Does |
||
31 | */ |
||
32 | 21 | public function __construct($path) |
|
36 | |||
37 | 8 | private function skipOperation($destination, $overwrite) |
|
41 | |||
42 | /** |
||
43 | * Move file to a new location. |
||
44 | * |
||
45 | * @param string $destination New destination of the file. |
||
46 | * @param int $overwrite Set some overwrite flags on the operation. |
||
47 | * @throws FileNotFoundException |
||
48 | * @throws FileNotWriteableException |
||
49 | */ |
||
50 | 4 | public function moveTo(string $destination, int $overwrite = self::OVERWRITE_ALL) : void |
|
59 | |||
60 | /** |
||
61 | * Get the size of the file. |
||
62 | * |
||
63 | * @return int |
||
64 | * @throws FileNotReadableException |
||
65 | */ |
||
66 | 2 | public function getSize() : int |
|
71 | |||
72 | /** |
||
73 | * Copy a file to a new destination. |
||
74 | * |
||
75 | * @param string $destination |
||
76 | * @param string $overwrite |
||
77 | * @throws FileNotFoundException |
||
78 | * @throws FileNotWriteableException |
||
79 | */ |
||
80 | 7 | public function copyTo(string $destination, int $overwrite = self::OVERWRITE_ALL) : void |
|
89 | |||
90 | /** |
||
91 | * @return string |
||
92 | * @throws FileNotReadableException |
||
93 | */ |
||
94 | 2 | public function getContents() |
|
99 | |||
100 | /** |
||
101 | * @param $contents |
||
102 | * @throws FileNotWriteableException |
||
103 | */ |
||
104 | 1 | public function putContents($contents) |
|
113 | |||
114 | 5 | public function delete() : void |
|
118 | |||
119 | 1 | public function getPath() : string |
|
123 | |||
124 | 3 | public function __toString() |
|
128 | |||
129 | } |
||
130 |