PostInstall   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 42
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A executeCommands() 0 9 2
B executeThemeCommands() 0 23 6
1
<?php
2
namespace PressCLI\Command;
3
4
use PressCLI\Option\Configuration;
5
6
class PostInstall
7
{
8
    /**
9
     * Executes the post install commands.
10
     */
11
    public static function executeCommands()
12
    {
13
        $config = Configuration::get();
14
15
        // Run commands.
16
        foreach ($config['commands']['postInstall'] as $command) {
17
            system($command);
18
        }
19
    }
20
21
    /**
22
     * Executes the post install theme commands.
23
     */
24
    public static function executeThemeCommands()
25
    {
26
        $config = Configuration::get();
27
        $themeName = isset($config['theme']['name']) ? $config['theme']['name'] : '';
28
        $commands = isset($config['commands']['postInstallTheme']) ? $config['commands']['postInstallTheme'] : [];
29
        if ( ! $themeName || ! $commands ) {
30
            return;
31
        }
32
33
        $rootDir = getcwd();
34
        $themeDir = "{$rootDir}/wp-content/themes/{$themeName}";
35
36
        // Change into the theme directory.
37
        chdir($themeDir);
38
39
        // Run commands.
40
        foreach ($commands as $command) {
41
            system($command);
42
        }
43
44
        // Change back to root directory.
45
        chdir($rootDir);
46
    }
47
}
48