| 1 | <?php |
||
| 13 | class FileStorage implements StorageInterface |
||
| 14 | { |
||
| 15 | public $path; |
||
| 16 | |||
| 17 | 3 | public function __construct($path = null) |
|
| 21 | |||
| 22 | 3 | protected function getFullPath($name) |
|
| 26 | |||
| 27 | 2 | public function has($name) |
|
| 31 | |||
| 32 | 2 | public function get($name) |
|
| 38 | |||
| 39 | 3 | public function set($name, $text) |
|
| 40 | { |
||
| 41 | 3 | $path = $this->getFullPath($name); |
|
| 42 | 3 | $dir = dirname($path); |
|
| 43 | 3 | if (!is_dir($dir)) { |
|
| 44 | 3 | if (!mkdir($dir, 0755, true)) { |
|
| 45 | throw new \Exception('Could not create storage'); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | 3 | return file_put_contents($path, $text); |
|
| 50 | } |
||
| 51 | |||
| 52 | public function remove($name) |
||
| 58 | } |
||
| 59 |