Passed
Push — master ( b89ee9...82ea21 )
by Sebastian
03:18
created

Composer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 12
c 1
b 0
f 0
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 16 1
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Console\Application;
13
14
use CaptainHook\App\Console\Command\Configuration;
15
use CaptainHook\App\Console\Command\Install;
16
use CaptainHook\App\Console\Runtime\Resolver;
17
use Composer\IO\IOInterface;
18
use CaptainHook\App\Console\Application as ConsoleApplication;
19
use CaptainHook\App\Console\IO\ComposerIO;
20
21
/**
22
 * Class Application
23
 *
24
 * @package CaptainHook
25
 * @author  Sebastian Feldmann <[email protected]>
26
 * @link    https://github.com/captainhookphp/captainhook
27
 * @since   Class available since Release 0.9.0
28
 */
29
class Composer extends ConsoleApplication
30
{
31
    /**
32
     * Composer Application constructor
33
     *
34
     * This is private so you have to use the 'create' method to setup it up.
35
     */
36
    private function __construct()
37
    {
38
        parent::__construct();
39
    }
40
41
    /**
42
     * Create a minimalistic composer application utilizing the composer IOInterface
43
     *
44
     * @param  \Composer\IO\IOInterface $io
45
     * @return \CaptainHook\App\Console\Application\Composer
46
     */
47
    public static function create(IOInterface $io): Composer
48
    {
49
        $proxyIO = new ComposerIO($io);
50
        $app     = new self();
51
52
        $install = new Install(new Resolver());
53
        $install->setIO($proxyIO);
54
        $app->add($install);
55
56
        $configuration = new Configuration();
57
        $configuration->setIO($proxyIO);
58
        $app->add($configuration);
59
60
        $app->setAutoExit(false);
61
62
        return $app;
63
    }
64
}
65