| Total Complexity | 6 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | final class FileSystem |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @param string $userProvidedPath |
||
| 12 | * @return string|null |
||
| 13 | */ |
||
| 14 | public static function getRealPathToReadableAndWritableFile($userProvidedPath) |
||
| 15 | { |
||
| 16 | $realPath = realpath(dirname($userProvidedPath)) . '/' . basename($userProvidedPath); |
||
| 17 | return is_file($realPath) && is_readable($realPath) && is_writable($realPath) ? $realPath : null; |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param string $path |
||
| 22 | * @return string[]|bool |
||
| 23 | */ |
||
| 24 | public static function readFileIntoArray($path) |
||
| 25 | { |
||
| 26 | return file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param string[] $lines |
||
| 31 | * @param string $path |
||
| 32 | */ |
||
| 33 | public static function writeArrayToFile(array $lines, $path) |
||
| 38 | } |
||
| 39 | } |
||
| 40 |