1 | <?php |
||
19 | trait FileTrait |
||
20 | { |
||
21 | /** |
||
22 | * Create directory recursively. |
||
23 | * |
||
24 | * @param string $directory |
||
25 | * @param int $perm |
||
26 | * |
||
27 | * @throws Exception |
||
28 | */ |
||
29 | protected function createDirectory($directory, $perm = 0777) |
||
43 | |||
44 | /** |
||
45 | * Write content to file. |
||
46 | * |
||
47 | * @param string $content |
||
48 | * @param string $target |
||
49 | * @param int $perm |
||
50 | * |
||
51 | * @throws Exception |
||
52 | */ |
||
53 | protected function writeFile($content, $target, $perm = 0666) |
||
61 | |||
62 | /** |
||
63 | * Chmod target file or directory. |
||
64 | * |
||
65 | * @param string $target |
||
66 | * @param int $perm |
||
67 | */ |
||
68 | protected function chmod($target, $perm = 0666) |
||
76 | |||
77 | /** |
||
78 | * Assert if directory is exist. |
||
79 | * |
||
80 | * @param string $directory |
||
81 | * |
||
82 | * @throws Exception |
||
83 | */ |
||
84 | private static function assertIsDirectory($directory) |
||
90 | |||
91 | /** |
||
92 | * Assert if directory is writable. |
||
93 | * |
||
94 | * @param string $directory |
||
95 | * |
||
96 | * @throws Exception |
||
97 | */ |
||
98 | private static function assertIsDirectoryWritable($directory) |
||
104 | } |
||
105 |