PluginProbe
Code Snippets / 3.10.1
Code Snippets v3.10.1
3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 3.0.1 All 64 releases
code-snippets / php / Flat_Files / Interfaces / Filesystem_Adapter.php

Filesystem_Adapter.php in Code Snippets 3.10.1, at php/Flat_Files/Interfaces/Filesystem_Adapter.php

94 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Code_Snippets\Flat_Files\Interfaces;
4
5 /**
6 * Interface for storing and loading from flat files.
7 */
8 interface Filesystem_Adapter {
9 /**
10 * Writes a string to a file.
11 *
12 * @param string $path Remote path to the file where to write the data.
13 * @param string $contents The data to write.
14 * @param int|false $chmod Optional. The file permissions as octal number, usually 0644. Default false.
15 *
16 * @return bool True on success, false on failure.
17 */
18 public function put_contents( string $path, string $contents, $chmod ): bool;
19
20 /**
21 * Checks if a file or directory exists.
22 *
23 * @param string $path Path to file or directory.
24 *
25 * @return bool Whether $path exists or not.
26 */
27 public function exists( string $path ): bool;
28
29 /**
30 * Deletes a file or directory.
31 *
32 * @param string $file Path to the file or directory.
33 * @param bool $recursive Optional. If set to true, deletes files and folders recursively.
34 * Default false.
35 * @param string|false $type Type of resource. 'f' for file, 'd' for directory.
36 * Default false.
37 *
38 * @return bool True on success, false on failure.
39 */
40 public function delete( string $file, bool $recursive = false, $type = false ): bool;
41
42 /**
43 * Checks if resource is a directory.
44 * *
45 *
46 * @param string $path Directory path.
47 *
48 * @return bool Whether $path is a directory.
49 */
50 public function is_dir( string $path ): bool;
51
52 /**
53 * Creates a directory.
54 *
55 * @param string $path Path for new directory.
56 * @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
57 * Default false.
58 *
59 * @return bool True on success, false on failure.
60 * /
61 */
62 public function mkdir( string $path, $chmod ): bool;
63
64 /**
65 * Deletes a directory.
66 *
67 * @param string $path Path to directory.
68 * @param bool $recursive Optional. Whether to recursively remove files/directories.
69 * Default false.
70 *
71 * @return bool True on success, false on failure.
72 */
73 public function rmdir( string $path, bool $recursive = false ): bool;
74
75 /**
76 * Changes filesystem permissions.
77 *
78 * @param string $path Path to the file.
79 * @param int|false $chmod Optional. The permissions as octal number, usually 0644 for files.
80 *
81 * @return bool True on success, false on failure.
82 */
83 public function chmod( string $path, $chmod ): bool;
84
85 /**
86 * Checks if a file or directory is writable.
87 *
88 * @param string $path Path to file or directory.
89 *
90 * @return bool Whether $path is writable.
91 */
92 public function is_writable( string $path ): bool;
93 }
94