Test Failed
Pull Request — master (#4)
by Ashoka
06:10 queued 15s
created

FilesInstaller::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
1
<?php
2
/**
3
 * Copyright MediaCT. All rights reserved.
4
 * https://www.mediact.nl
5
 */
6
7
namespace Mediact\TestingSuite\Composer\Installer;
8
9
use Composer\IO\IOInterface;
10
use Mediact\Composer\FileInstaller as ComposerFileInstaller;
11
use Mediact\TestingSuite\Composer\MappingResolver;
12
13
class FilesInstaller implements InstallerInterface
14
{
15
    /** @var MappingResolver */
16
    private $mappingResolver;
17
18
    /** @var ComposerFileInstaller */
19
    private $fileInstaller;
20
21
    /** @var IOInterface */
22
    private $io;
23
24
    /**
25
     * Constructor.
26
     *
27
     * @param MappingResolver       $mappingResolver
28
     * @param ComposerFileInstaller $fileInstaller
29
     * @param IOInterface           $io
30
     */
31
    public function __construct(
32
        MappingResolver $mappingResolver,
33
        ComposerFileInstaller $fileInstaller,
34
        IOInterface $io
35
    ) {
36
        $this->mappingResolver = $mappingResolver;
37
        $this->fileInstaller   = $fileInstaller;
38
        $this->io              = $io;
39
    }
40
41
    /**
42
     * Install.
43
     *
44
     * @return void
45
     */
46
    public function install()
47
    {
48
        foreach ($this->mappingResolver->resolve() as $mapping) {
49
            if (file_exists($mapping->getDestination())) {
50
                continue;
51
            }
52
53
            $this->fileInstaller->installFile($mapping);
54
55
            $this->io->write(
56
                sprintf(
57
                    '<info>Installed:</info> %s',
58
                    $mapping->getRelativeDestination()
59
                )
60
            );
61
        }
62
    }
63
}
64