Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
InteractsWithDirectories | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
needsDirectory | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
needsDirectories | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Hyde\Framework\Concerns; |
4 | |
5 | /** |
6 | * @see \Tests\Unit\InteractsWithDirectoriesConcernTest |
7 | */ |
8 | trait InteractsWithDirectories |
9 | { |
10 | /** |
11 | * Ensure the supplied directory exist by creating it if it does not. |
12 | * |
13 | * @param string $directory absolute file path to the directory |
14 | */ |
15 | public function needsDirectory(string $directory): void |
16 | { |
17 | if (! file_exists($directory)) { |
18 | mkdir($directory, recursive: true); |
19 | } |
20 | } |
21 | |
22 | /** |
23 | * Ensure the supplied directories exist by creating them if they don't. |
24 | * |
25 | * @param array $directories array with absolute file paths to the directories |
26 | */ |
27 | public function needsDirectories(array $directories): void |
28 | { |
29 | foreach ($directories as $directory) { |
30 | $this->needsDirectory($directory); |
31 | } |
32 | } |
33 | } |