AuthorNamePrompt::getValues()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
crap 1
1
<?php
2
3
namespace CL\ComposerInit\Prompt;
4
5
use CL\ComposerInit\GitConfig;
6
use Symfony\Component\Console\Output\OutputInterface;
7
use Symfony\Component\Console\Helper\DialogHelper;
8
9
/**
10
 * @author    Ivan Kerin <[email protected]>
11
 * @copyright (c) 2014 Clippings Ltd.
12
 * @license   http://spdx.org/licenses/BSD-3-Clause
13
 */
14
class AuthorNamePrompt implements PromptInterface
15
{
16
    /**
17
     * @var GitConfig
18
     */
19
    private $gitConfig;
20
21
    /**
22
     * @param GitConfig $gitConfig
23
     */
24 1
    public function __construct(GitConfig $gitConfig)
25
    {
26 1
        $this->gitConfig = $gitConfig;
27 1
    }
28
29
    /**
30
     * @return GitConfig
31
     */
32 1
    public function getGitConfig()
33
    {
34 1
        return $this->gitConfig;
35
    }
36
37
    /**
38
     * @return string
39
     */
40 1
    public function getDefault()
41
    {
42 1
        return $this->gitConfig->get('user.name');
43
    }
44
45
    /**
46
     * @param  OutputInterface $output
47
     * @param  DialogHelper    $dialog
48
     * @return array
49
     */
50 1
    public function getValues(OutputInterface $output, DialogHelper $dialog)
51
    {
52 1
        $default = $this->getDefault();
53
54 1
        $value = $dialog->ask(
55 1
            $output,
56 1
            "<info>Author name</info> ({$default}): ",
57
            $default
58 1
        );
59
60 1
        return ['author_name' => $value];
61
    }
62
}
63