Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
CreatesDefaultDirectories | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
__invoke | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
3 | |||
getRequiredDirectories | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace Hyde\Framework\Actions; |
4 | |
5 | use Hyde\Framework\Hyde; |
6 | use JetBrains\PhpStorm\Pure; |
7 | |
8 | /** |
9 | * Create the default directories required by the Application. |
10 | * |
11 | * @deprecated as Hyde is bringing support for changing the default directories. |
12 | * The directories needed will be created (if needed) when the filesystem |
13 | * needs to access them. The default directories may be created in the TestCase. |
14 | * |
15 | * To prevent any issues with file generations, this action |
16 | * is automatically whenever the application is booted. |
17 | * |
18 | * This behavior is handled in the Service Provider. |
19 | * @see \Hyde\Framework\HydeServiceProvider |
20 | */ |
21 | class CreatesDefaultDirectories |
22 | { |
23 | /** |
24 | * The directories required by the application. |
25 | * |
26 | * @var array |
27 | */ |
28 | protected array $requiredDirectories = [ |
29 | '_pages', |
30 | '_posts', |
31 | '_media', |
32 | '_docs', |
33 | '_site', |
34 | '_site/posts', |
35 | '_site/media', |
36 | '_site/docs', |
37 | ]; |
38 | |
39 | /** |
40 | * Execute the action. |
41 | * |
42 | * @return void |
43 | */ |
44 | public function __invoke(): void |
45 | { |
46 | foreach ($this->requiredDirectories as $directory) { |
47 | // Does the directory exist? // Otherwise, create it. |
48 | is_dir(Hyde::path($directory)) || mkdir(Hyde::path($directory), recursive: true); |
49 | } |
50 | } |
51 | |
52 | /** |
53 | * Retrieve the array of default directories. |
54 | * |
55 | * @return array |
56 | */ |
57 | #[Pure] |
58 | public static function getRequiredDirectories(): array |
59 | { |
60 | return (new CreatesDefaultDirectories)->requiredDirectories; |
61 | } |
62 | } |