KeywordsQuestion   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 32
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 12 1
A setAnswer() 0 8 2
1
<?php
2
namespace Samurai\Project\Question;
3
4
use Samurai\Task\ITask;
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
use Symfony\Component\Console\Question\Question as SimpleQuestion;
8
9
/**
10
 * Class KeywordsQuestion
11
 * @package Samurai\Project\Question
12
 * @author Raphaël Lefebvre <[email protected]>
13
 */
14
class KeywordsQuestion extends Question
15
{
16
    /**
17
     * @param InputInterface $input
18
     * @param OutputInterface $output
19
     * @return int
20
     */
21 4
    public function execute(InputInterface $input, OutputInterface $output)
22
    {
23 4
        $answer = $this->ask(
24 4
            $input,
25 4
            $output,
26 4
            new SimpleQuestion('<question>Enter your project keywords (comma separated):</question>')
27 4
        );
28
29 4
        $this->setAnswer($answer);
30
31 4
        return ITask::NO_ERROR_CODE;
32
    }
33
34
    /**
35
     * @param $answer
36
     */
37 4
    private function setAnswer($answer)
38
    {
39 4
        if ($answer) {
40 2
            $this->getProject()->setKeywords(array_map('trim', explode(',', $answer)));
41 2
        } else {
42 2
            $this->getProject()->setKeywords([]);
43
        }
44 4
    }
45
}
46