Passed
Push — master ( a5e8db...945884 )
by Danny
02:33
created

PostInstall::executeCommands()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
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
        $rootDir = getcwd();
28
        $themeDir = "{$rootDir}/wp-content/themes/{$config['theme']['name']}";
29
30
        // Change into the theme directory.
31
        chdir($themeDir);
32
33
        // Run commands.
34
        foreach ($config['commands']['postInstallTheme'] as $command) {
35
            system($command);
36
        }
37
38
        // Change back to root directory.
39
        chdir($rootDir);
40
    }
41
}
42