ChangelogRepositoryFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 6
rs 10
cc 1
nc 1
nop 2
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 \Vaimo\ComposerChangelogs\Composer\Context
12
     */
13
    private $composerCtx;
14
15
    /**
16
     * @var \Symfony\Component\Console\Output\OutputInterface
17
     */
18
    private $output;
19
20
    /**
21
     * @param \Vaimo\ComposerChangelogs\Composer\Context $composerCtx
22
     * @param \Symfony\Component\Console\Output\OutputInterface $output
23
     */
24
    public function __construct(
25
        \Vaimo\ComposerChangelogs\Composer\Context $composerCtx,
26
        ?\Symfony\Component\Console\Output\OutputInterface $output = null
27
    ) {
28
        $this->composerCtx = $composerCtx;
29
        $this->output = $output;
30
    }
31
    
32
    public function create($fromSource)
33
    {
34
        $pkgResolverFactory = new PackageResolverFactory($this->composerCtx);
35
        
36
        $chLogLoaderFactory = new Changelog\LoaderFactory($this->composerCtx);
37
38
        $chLogLoader = $chLogLoaderFactory->create($fromSource);
39
        
40
        $validator = new \Vaimo\ComposerChangelogs\Validators\ChangelogValidator($chLogLoader, array(
41
            'failure' => '<error>%s</error>',
42
            'success' => '<info>%s</info>'
43
        ));
44
45
        $outputGenerator = new \Vaimo\ComposerChangelogs\Console\OutputGenerator($this->output);
46
47
        return new \Vaimo\ComposerChangelogs\Repositories\ChangelogRepository(
48
            $pkgResolverFactory->create(),
49
            $chLogLoader,
50
            $validator,
51
            $outputGenerator
52
        );
53
    }
54
}
55