Completed
Push — master ( d234f3...0a4926 )
by Jan Philipp
47s queued 12s
created

ProcessEnvironment::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Psh\ScriptRuntime\Execution;
4
5
use Shopware\Psh\Config\Template;
6
use Shopware\Psh\Config\ValueProvider;
7
use Symfony\Component\Process\Process;
8
use function array_merge;
9
10
/**
11
 * Create representation of the current environment variables and constants
12
 */
13
class ProcessEnvironment
14
{
15
    /**
16
     * @var ValueProvider[]
17
     */
18
    private $constants;
19
20
    /**
21
     * @var ValueProvider[]
22
     */
23
    private $variables;
24
25
    /**
26
     * @var Template[]
27
     */
28
    private $templates;
29
30
    /**
31
     * @var ValueProvider[]
32
     */
33
    private $dotenvVariables;
34
35
    /**
36
     * @param ValueProvider[] $constants
37
     * @param ValueProvider[] $variables
38
     * @param Template[] $templates
39
     * @param ValueProvider[] $dotenvVars
40
     */
41
    public function __construct(array $constants, array $variables, array $templates, array $dotenvVars)
42
    {
43
        $this->constants = $constants;
44
        $this->variables = $variables;
45
        $this->templates = $templates;
46
        $this->dotenvVariables = $dotenvVars;
47
    }
48
49
    /**
50
     * @return ValueProvider[]
51
     */
52
    public function getAllValues(): array
53
    {
54
        return array_merge(
55
            $this->constants,
56
            $this->dotenvVariables,
57
            $this->variables
58
        );
59
    }
60
61
    /**
62
     * @return Template[]
63
     */
64
    public function getTemplates(): array
65
    {
66
        return $this->templates;
67
    }
68
69
    public function createProcess(string $shellCommand): Process
70
    {
71
        return Process::fromShellCommandline($shellCommand);
72
    }
73
}
74