Conditions | 3 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | 20 | public static function checkDirectory(string $directory): string |
|
33 | { |
||
34 | 20 | $dir = realpath($directory); |
|
35 | |||
36 | 20 | if (false === $dir) { |
|
37 | 18 | @mkdir( |
|
|
|||
38 | 18 | $directory, |
|
39 | 18 | 0777, |
|
40 | 18 | true |
|
41 | ); |
||
42 | |||
43 | 18 | $dir = realpath($directory); |
|
44 | } |
||
45 | |||
46 | 20 | if (false === $dir) { |
|
47 | // @codeCoverageIgnoreStart |
||
48 | throw new Exception("Can't get directory $directory."); |
||
49 | // @codeCoverageIgnoreEnd |
||
50 | } |
||
51 | |||
52 | 20 | return $dir; |
|
53 | } |
||
83 |
If you suppress an error, we recommend checking for the error condition explicitly: