| Conditions | 6 |
| Paths | 11 |
| Total Lines | 27 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | public function __construct($storagePath) |
||
| 21 | { |
||
| 22 | |||
| 23 | if (!$storagePath) |
||
| 24 | throw new ErrorException('Storage path not set for path generator.'); |
||
| 25 | |||
| 26 | if (!file_exists($storagePath)) |
||
| 27 | mkdir($storagePath); |
||
| 28 | |||
| 29 | if (!file_exists($storagePath)) |
||
| 30 | throw new ErrorException('Unable to create storage.'); |
||
| 31 | |||
| 32 | $folderName0 = rand(10, 99); |
||
| 33 | $folderName1 = rand(10, 99); |
||
| 34 | |||
| 35 | $path0 = DIRECTORY_SEPARATOR . $folderName0; |
||
| 36 | $path1 = DIRECTORY_SEPARATOR . $folderName0 . DIRECTORY_SEPARATOR . $folderName1; |
||
| 37 | |||
| 38 | $fullPath0 = $storagePath . $path0; |
||
| 39 | $fullPath1 = $storagePath . $path1; |
||
| 40 | |||
| 41 | if (!file_exists($fullPath0)) |
||
| 42 | mkdir($fullPath0); |
||
| 43 | if (!file_exists($fullPath1)) |
||
| 44 | mkdir($fullPath1); |
||
| 45 | |||
| 46 | $this->path = $path1 . DIRECTORY_SEPARATOR . md5(rand(0, 1000) . time()); |
||
| 47 | } |
||
| 53 | } |