BootstrapFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A create() 0 23 3
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\Interfaces\ListResolverInterface as ListResolver;
9
use Vaimo\ComposerPatches\Repository\PatchesApplier\ListResolvers;
10
use Vaimo\ComposerPatches\Strategies\OutputStrategy;
11
use Vaimo\ComposerPatches\Patch\Definition as Patch;
12
13
class BootstrapFactory
14
{
15
    /**
16
     * @var \Vaimo\ComposerPatches\Composer\Context
17
     */
18
    private $composerContext;
19
20
    /**
21
     * @var \Composer\IO\IOInterface
22
     */
23
    private $appIO;
24
25
    /**
26
     * @param \Vaimo\ComposerPatches\Composer\Context $composerContext
27
     * @param \Composer\IO\IOInterface $appIO
28
     */
29
    public function __construct(
30
        \Vaimo\ComposerPatches\Composer\Context $composerContext,
31
        \Composer\IO\IOInterface $appIO
32
    ) {
33
        $this->composerContext = $composerContext;
34
        $this->appIO = $appIO;
35
    }
36
37
    public function create(
38
        ConfigFactory $configFactory,
39
        ListResolver $listResolver = null,
40
        OutputStrategy $outputStrategy = null
41
    ) {
42
        if ($listResolver === null) {
43
            $listResolver = new ListResolvers\ChangesListResolver(
44
                new ListResolvers\DirectListResolver()
45
            );
46
        }
47
48
        if ($outputStrategy === null) {
49
            $outputStrategy = new OutputStrategy(
50
                array(Patch::STATUS_NEW, Patch::STATUS_CHANGED, Patch::STATUS_MATCH)
51
            );
52
        }
53
54
        return new \Vaimo\ComposerPatches\Bootstrap(
55
            $this->composerContext,
56
            $this->appIO,
57
            $configFactory,
58
            $listResolver,
59
            $outputStrategy
60
        );
61
    }
62
}
63