Passed
Push — master ( 655a42...ee1d9b )
by Allan
02:04
created

ChangelogRepositoryFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 18
dl 0
loc 46
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 22 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\ComposerChangelogs\Factories;
7
8
class ChangelogRepositoryFactory
9
{
10
    /**
11
     * @var \Composer\Composer
12
     */
13
    private $composerRuntime;
14
15
    /**
16
     * @var \Symfony\Component\Console\Output\OutputInterface
17
     */
18
    private $output;
19
20
    /**
21
     * @param \Composer\Composer $composerRuntime
22
     * @param \Symfony\Component\Console\Output\OutputInterface $output
23
     */
24
    public function __construct(
25
        \Composer\Composer $composerRuntime,
26
        \Symfony\Component\Console\Output\OutputInterface $output = null
27
    ) {
28
        $this->composerRuntime = $composerRuntime;
29
        $this->output = $output;
30
    }
31
    
32
    public function create($fromSource)
33
    {
34
        $pkgResolverFactory = new PackageResolverFactory(
35
            $this->composerRuntime
36
        );
37
        
38
        $chLogLoaderFactory = new Changelog\LoaderFactory($this->composerRuntime);
39
40
        $chLogLoader = $chLogLoaderFactory->create($fromSource);
41
        
42
        $validator = new \Vaimo\ComposerChangelogs\Validators\ChangelogValidator($chLogLoader, array(
43
            'failure' => '<error>%s</error>',
44
            'success' => '<info>%s</info>'
45
        ));
46
47
        $outputGenerator = new \Vaimo\ComposerChangelogs\Console\OutputGenerator($this->output);
48
49
        return new \Vaimo\ComposerChangelogs\Repositories\ChangelogRepository(
50
            $pkgResolverFactory->create(),
51
            $chLogLoader,
52
            $validator,
53
            $outputGenerator
54
        );
55
    }
56
}
57