1 | <?php |
||
20 | class File |
||
21 | { |
||
22 | /** |
||
23 | * Path to file |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $path; |
||
28 | |||
29 | /** |
||
30 | * File constructor. |
||
31 | * |
||
32 | * @param string $path |
||
33 | */ |
||
34 | 22 | public function __construct($path) |
|
38 | |||
39 | /** |
||
40 | * Path getter. |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | 1 | public function getPath() |
|
48 | |||
49 | /** |
||
50 | * Checks whether the file exists. |
||
51 | * |
||
52 | * @return bool |
||
53 | */ |
||
54 | 12 | public function exists() |
|
58 | |||
59 | /** |
||
60 | * Reads json file. |
||
61 | * |
||
62 | * @throws \RuntimeException |
||
63 | * @return string |
||
64 | */ |
||
65 | 11 | public function read() |
|
72 | |||
73 | /** |
||
74 | * Writes file. |
||
75 | * |
||
76 | * @param string $content |
||
77 | * @throws \RuntimeException |
||
78 | */ |
||
79 | 9 | public function write($content) |
|
86 | |||
87 | /** |
||
88 | * Check if file exists and isn't writable |
||
89 | * |
||
90 | * @return void |
||
91 | * @throws \RuntimeException |
||
92 | */ |
||
93 | 9 | private function checkFile() |
|
99 | |||
100 | /** |
||
101 | * Create directory if necessary |
||
102 | * |
||
103 | * @throws \RuntimeException |
||
104 | */ |
||
105 | 8 | private function checkDir() |
|
117 | } |
||
118 |