SharedPackagePlugin   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 11

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 2
c 3
b 1
f 2
lcom 0
cbo 11
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setConfig() 0 8 1
A activate() 0 16 1
1
<?php
2
3
/*
4
 * This file is part of the "Composer Shared Package Plugin" package.
5
 *
6
 * https://github.com/Letudiant/composer-shared-package-plugin
7
 *
8
 * For the full license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LEtudiant\Composer;
13
14
use Composer\Composer;
15
use Composer\Installer\LibraryInstaller;
16
use Composer\IO\IOInterface;
17
use Composer\Plugin\PluginInterface;
18
use LEtudiant\Composer\Data\Package\SharedPackageDataManager;
19
use LEtudiant\Composer\Installer\Config\SharedPackageInstallerConfig;
20
use LEtudiant\Composer\Installer\Solver\SharedPackageSolver;
21
use LEtudiant\Composer\Installer\SharedPackageInstaller;
22
use LEtudiant\Composer\Installer\Solver\SharedPackageInstallerSolver;
23
use LEtudiant\Composer\Util\SymlinkFilesystem;
24
25
/**
26
 * @author Sylvain Lorinet <[email protected]>
27
 */
28
class SharedPackagePlugin implements PluginInterface
29
{
30
    /**
31
     * @param Composer    $composer
32
     * @param IOInterface $io
33
     */
34
    public function activate(Composer $composer, IOInterface $io)
35
    {
36
        $config = $this->setConfig($composer);
37
38
        $composer->getInstallationManager()->addInstaller(new SharedPackageInstallerSolver(
39
            new SharedPackageSolver($config),
40
            new SharedPackageInstaller(
41
                $io,
42
                $composer,
43
                new SymlinkFilesystem(),
44
                new SharedPackageDataManager($composer),
45
                $config
46
            ),
47
            new LibraryInstaller($io, $composer)
48
        ));
49
    }
50
51
    /**
52
     * @param Composer $composer
53
     *
54
     * @return SharedPackageInstallerConfig
55
     */
56
    protected function setConfig(Composer $composer)
57
    {
58
        return new SharedPackageInstallerConfig(
59
            $composer->getConfig()->get('vendor-dir'),
60
            $composer->getConfig()->get('vendor-dir', 1),
61
            $composer->getPackage()->getExtra()
62
        );
63
    }
64
}
65