PatcherConfigReaderFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 14 2
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Factories;
7
8
use Vaimo\ComposerPatches\Config as PluginConfig;
9
use Vaimo\ComposerPatches\Package\ConfigExtractors;
10
11
class PatcherConfigReaderFactory
12
{
13
    /**
14
     * @var \Composer\Composer
15
     */
16
    private $composer;
17
18
    public function __construct(
19
        \Composer\Composer $composer
20
    ) {
21
        $this->composer = $composer;
22
    }
23
24
    public function create(PluginConfig $pluginConfig)
25
    {
26
        $composerConfig = $this->composer->getConfig();
27
28
        $packageInfoResolver = new \Vaimo\ComposerPatches\Package\InfoResolver(
29
            $this->composer->getInstallationManager(),
30
            $composerConfig->get(\Vaimo\ComposerPatches\Composer\ConfigKeys::VENDOR_DIR)
31
        );
32
33
        $infoExtractor = $pluginConfig->shouldPreferOwnerPackageConfig()
34
            ? new ConfigExtractors\VendorConfigExtractor($packageInfoResolver)
35
            : new ConfigExtractors\InstalledConfigExtractor();
36
37
        return new \Vaimo\ComposerPatches\Patcher\ConfigReader($infoExtractor);
38
    }
39
}
40