1 | <?php namespace KamranAhmed\Smasher; |
||
11 | class Path |
||
12 | { |
||
13 | /** |
||
14 | * @var string Path which is being processed |
||
15 | */ |
||
16 | private $path; |
||
17 | |||
18 | /** |
||
19 | * Path constructor. |
||
20 | * |
||
21 | * @param string $path |
||
22 | */ |
||
23 | 17 | public function __construct($path = '') |
|
27 | |||
28 | /** |
||
29 | * Validates whether the path exists or not |
||
30 | * |
||
31 | * @throws \KamranAhmed\Smasher\Exceptions\UnreadablePathException |
||
32 | * @return bool |
||
33 | */ |
||
34 | 9 | public function validate() |
|
42 | |||
43 | /** |
||
44 | * Writes content to the specified path |
||
45 | * |
||
46 | * @param $content |
||
47 | * @throws \KamranAhmed\Smasher\Exceptions\InvalidPathException |
||
48 | * @return int |
||
49 | */ |
||
50 | 3 | public function saveFileContent($content) |
|
60 | |||
61 | /** |
||
62 | * Gets the path which is being operated |
||
63 | * @return string |
||
64 | */ |
||
65 | 2 | public function getPath() |
|
69 | |||
70 | /** |
||
71 | * Sets the path to operate on |
||
72 | * @param $path |
||
73 | */ |
||
74 | 9 | public function setPath($path) |
|
78 | |||
79 | /** |
||
80 | * Creates the path based upon the type of it |
||
81 | * @param array $detail |
||
82 | */ |
||
83 | 4 | public function createItem($detail = []) |
|
111 | |||
112 | /** |
||
113 | * Gets the detail about the currently set path |
||
114 | * |
||
115 | * @return array |
||
116 | */ |
||
117 | 6 | public function getDetail() |
|
140 | |||
141 | /** |
||
142 | * Gets the name of the currently set path |
||
143 | * |
||
144 | * @return mixed |
||
145 | */ |
||
146 | 6 | public function getName() |
|
152 | |||
153 | /** |
||
154 | * Gets the type of path i.e. whether it is file, link or dir |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | 6 | public function getType() |
|
170 | |||
171 | /** |
||
172 | * Returns the size of the path in bytes |
||
173 | * |
||
174 | * @return int |
||
175 | */ |
||
176 | 6 | public function getSize() |
|
180 | |||
181 | /** |
||
182 | * Returns the permission that the path has |
||
183 | * |
||
184 | * @return string |
||
185 | */ |
||
186 | 6 | public function getMode() |
|
190 | |||
191 | /** |
||
192 | * Returns the detail of the path owner |
||
193 | * |
||
194 | * @return array |
||
195 | */ |
||
196 | 6 | public function getOwner() |
|
200 | |||
201 | /** |
||
202 | * Gets the last date when the path was modified |
||
203 | * |
||
204 | * @return string |
||
205 | */ |
||
206 | 6 | public function getLastModified() |
|
210 | |||
211 | /** |
||
212 | * Returns the detail of the path group |
||
213 | * |
||
214 | * @return array |
||
215 | */ |
||
216 | 6 | public function getGroup() |
|
220 | |||
221 | /** |
||
222 | * Gets the real path for the path |
||
223 | * |
||
224 | * @return string |
||
225 | */ |
||
226 | 3 | public function getRealPath() |
|
230 | |||
231 | /** |
||
232 | * If the set path is file, it returns the contents of the file |
||
233 | * |
||
234 | * @return string |
||
235 | */ |
||
236 | 8 | public function getFileContent() |
|
240 | } |
||
241 |