| Conditions | 5 |
| Paths | 2 |
| Total Lines | 9 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function __construct($path) |
||
|
|
|||
| 16 | { |
||
| 17 | $basePath = $_SERVER['DOCUMENT_ROOT']; |
||
| 18 | $path = $basePath . '/' . trim($path, '\/'); |
||
| 19 | if (empty($path) || !(is_dir($path) || is_file($path)) || !is_writable($path)) { |
||
| 20 | throw new Exception('Путь не может быть пустым или нет доступа'); |
||
| 21 | } |
||
| 22 | $this->path = $path; |
||
| 23 | } |
||
| 24 | |||
| 37 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: