FilesInstaller   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 15
c 1
b 0
f 0
dl 0
loc 46
ccs 14
cts 14
cp 1
rs 10

2 Methods

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