| Total Complexity | 7 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | class DirDesc extends AFiles |
||
| 18 | { |
||
| 19 | use TToString; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param string[] $path |
||
| 23 | * @param bool $errorOnFail |
||
| 24 | * @throws FilesException |
||
| 25 | * @throws PathsException |
||
| 26 | * @return string |
||
| 27 | */ |
||
| 28 | 2 | public function get(array $path, bool $errorOnFail = false): string |
|
| 29 | { |
||
| 30 | try { |
||
| 31 | 2 | return $this->toString(Stuff::arrayToPath($path), $this->lib->readFile($this->getPath($path))); |
|
| 32 | 2 | } catch (FilesException $ex) { |
|
| 33 | 2 | if (!$errorOnFail) { |
|
| 34 | 2 | return ''; |
|
| 35 | } |
||
| 36 | 1 | throw $ex; |
|
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param string[] $path |
||
| 42 | * @param string $content |
||
| 43 | * @throws FilesException |
||
| 44 | * @throws PathsException |
||
| 45 | * @return bool |
||
| 46 | */ |
||
| 47 | 2 | public function set(array $path, string $content): bool |
|
| 48 | { |
||
| 49 | 2 | return $this->lib->saveFile($this->getPath($path), $content); |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @param string[] $path |
||
| 54 | * @throws FilesException |
||
| 55 | * @throws PathsException |
||
| 56 | * @return bool |
||
| 57 | */ |
||
| 58 | 2 | public function remove(array $path): bool |
|
| 59 | { |
||
| 60 | 2 | return $this->lib->deleteFile($this->getPath($path)); |
|
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @param string[] $path |
||
| 65 | * @throws FilesException |
||
| 66 | * @throws PathsException |
||
| 67 | * @return bool |
||
| 68 | */ |
||
| 69 | 2 | public function canUse(array $path): bool |
|
| 70 | { |
||
| 71 | 2 | return $this->lib->isDir(array_merge($path, [$this->config->getDescDir()])); |
|
| 72 | } |
||
| 73 | |||
| 74 | 2 | public function getPath(array $path): array |
|
| 77 | } |
||
| 78 | } |
||
| 79 |