MicroAppInstaller::install()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\Installer\ApplicationType;
6
7
use Antidot\Installer\Question\AdditionalPackages;
8
use Antidot\Installer\Template\ComposerJson;
9
use Antidot\Installer\Template\FileStructureFactory;
10
use Antidot\Installer\Template\Micro\FileStructure;
11
use Composer\IO\IOInterface;
12
13
use function array_merge;
14
15
class MicroAppInstaller implements App
16
{
17
    public const DEPENDENCIES = [
18
        'antidot-fw/framework' => '^0.1.2',
19
        'antidot-fw/container' => '^0.1.1',
20
        'antidot-fw/fast-router-adapter' => '^0.1.0',
21
    ];
22
23
    private FileStructureFactory $fileStructure;
24
    private ComposerJson $manipulator;
25
    private DockerEnvironmentInstaller $dockerInstaller;
26
    private AdditionalPackages $additionalPackages;
27
28 2
    public function __construct(IOInterface $io, ComposerJson $manipulator)
29
    {
30 2
        $this->manipulator = $manipulator;
31 2
        $this->additionalPackages = new AdditionalPackages($io);
32 2
        $this->dockerInstaller = new DockerEnvironmentInstaller($io);
33 2
        $this->fileStructure = new FileStructure();
34 2
    }
35
36 1
    public function install(string $installationPath): void
37
    {
38 1
        $additionalPackages = $this->additionalPackages->ask();
39 1
        $this->dockerInstaller->install($installationPath);
40 1
        $this->fileStructure->create($installationPath);
41 1
        $this->manipulator->prepare($installationPath, array_merge(self::DEPENDENCIES, $additionalPackages), []);
42 1
    }
43
}
44