BootstrapFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 53
rs 10
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
    /**
38
     * @param ConfigFactory $configFactory
39
     * @param ListResolver|null $listResolver
40
     * @param OutputStrategy|null $outputStrategy
41
     * @return \Vaimo\ComposerPatches\Bootstrap
42
     */
43
    public function create(
44
        ConfigFactory $configFactory,
45
        $listResolver = null,
46
        $outputStrategy = null
47
    ) {
48
        if ($listResolver === null) {
49
            $listResolver = new ListResolvers\ChangesListResolver(
50
                new ListResolvers\DirectListResolver()
51
            );
52
        }
53
54
        if ($outputStrategy === null) {
55
            $outputStrategy = new OutputStrategy(
56
                array(Patch::STATUS_NEW, Patch::STATUS_CHANGED, Patch::STATUS_MATCH)
57
            );
58
        }
59
60
        return new \Vaimo\ComposerPatches\Bootstrap(
61
            $this->composerContext,
62
            $this->appIO,
63
            $configFactory,
64
            $listResolver,
65
            $outputStrategy
66
        );
67
    }
68
}
69