| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4.5923 |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 45 | 40 | public static function getTempBaseDir() |
|
| 46 | { |
||
| 47 | 40 | $dirs = self::$tempDirs; |
|
| 48 | // Fallback to sys temp dir |
||
| 49 | 40 | $dirs[] = sys_get_temp_dir(); |
|
| 50 | |||
| 51 | 40 | foreach ($dirs as $directory) { |
|
| 52 | 40 | if (file_exists($directory)) { |
|
| 53 | 40 | $baseDir = $directory . DIRECTORY_SEPARATOR . 'paraunit'; |
|
| 54 | |||
| 55 | try { |
||
| 56 | 40 | self::mkdirIfNotExists($baseDir); |
|
| 57 | |||
| 58 | 40 | return $baseDir; |
|
| 59 | } catch (\RuntimeException $e) { |
||
| 60 | // ignore and try next dir |
||
| 61 | } |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | throw new \RuntimeException('Unable to create a temporary directory'); |
||
| 66 | } |
||
| 67 | |||
| 86 |