Bootstrap   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 45
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A preloadPluginClasses() 0 21 1
A __construct() 0 6 1
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Composer\Plugin;
7
8
class Bootstrap
9
{
10
    /**
11
     * @var \Composer\Composer
12
     */
13
    private $composer;
14
15
    /**
16
     * @var \Vaimo\ComposerPatches\Composer\Context
17
     */
18
    private $composerContext;
19
20
    /**
21
     * @param \Composer\Composer $composer
22
     * @param \Vaimo\ComposerPatches\Composer\Context $composerContext
23
     */
24
    public function __construct(
25
        \Composer\Composer $composer,
26
        \Vaimo\ComposerPatches\Composer\Context $composerContext
27
    ) {
28
        $this->composer = $composer;
29
        $this->composerContext = $composerContext;
30
    }
31
32
    public function preloadPluginClasses()
33
    {
34
        $installationManager = $this->composer->getInstallationManager();
35
        $composerConfig = $this->composer->getConfig();
36
37
        $packageResolver = new \Vaimo\ComposerPatches\Composer\Plugin\PackageResolver(
38
            array($this->composer->getPackage())
39
        );
40
41
        $packageInfoResolver = new \Vaimo\ComposerPatches\Package\InfoResolver(
42
            $installationManager,
43
            $composerConfig->get(\Vaimo\ComposerPatches\Composer\ConfigKeys::VENDOR_DIR)
44
        );
45
46
        $sourcesPreloader = new \Vaimo\ComposerPatches\Package\SourcesPreloader($packageInfoResolver);
47
48
        $packages = $this->composerContext->getActivePackages();
49
50
        $pluginPackage = $packageResolver->resolveForNamespace($packages, __CLASS__);
51
52
        $sourcesPreloader->preload($pluginPackage);
53
    }
54
}
55