Application::__construct()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 2

Importance

Changes 5
Bugs 2 Features 0
Metric Value
c 5
b 2
f 0
dl 0
loc 24
ccs 17
cts 17
cp 1
rs 8.9713
cc 2
eloc 15
nc 2
nop 1
crap 2
1
<?php
2
3
namespace CL\ComposerInit;
4
5
use GuzzleHttp\Client;
6
use CL\ComposerInit\Prompt\Prompts;
7
use CL\ComposerInit\SearchCommand;
8
use CL\ComposerInit\UseCommand;
9
10
class Application extends \Symfony\Component\Console\Application
11
{
12
    /**
13
     * @var Container
14
     */
15
    private $app;
16
17 2
    public function __construct($tokenFile = '~/.composer-init')
18
    {
19 2
        parent::__construct('Composer Init', '0.3');
20
21 2
        $packagist = new Client(['base_uri' => 'https://packagist.org']);
22 2
        $token = new Token($tokenFile);
23
24 2
        $githubOptions = ['base_uri' => 'https://api.github.com'];
25
26 2
        if (null !== $token->get()) {
27 1
            $githubOptions['query']['access_token'] = $token->get();
28 1
        }
29
30 2
        $github = new Client($githubOptions);
31
32 2
        $gitConfig = new GitConfig();
33 2
        $inflector = new Inflector();
34 2
        $prompts = new Prompts($gitConfig, $github, $inflector);
35 2
        $template = new Template($github);
36
37 2
        $this->add(new SearchCommand($packagist));
38 2
        $this->add(new UseCommand($template, $prompts, $packagist));
39 2
        $this->add(new TokenCommand($token));
40 2
    }
41
}
42