DirectoryPathQuestion::execute()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 8
cts 8
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 6
nop 2
crap 4
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
8
/**
9
 * Class BootstrapQuestion
10
 * @package Samurai\Project\Question
11
 * @author Raphaël Lefebvre <[email protected]>
12
 */
13
class DirectoryPathQuestion extends Question
14
{
15
    /**
16
     * @param InputInterface $input
17
     * @param OutputInterface $output
18
     * @return int
19
     */
20 5
    public function execute(InputInterface $input, OutputInterface $output)
21
    {
22 5
        $optionValue = $input->getOption('dir');
23 5
        if($optionValue){
24 2
            $this->getProject()->setDirectoryPath(getcwd() . DIRECTORY_SEPARATOR . $optionValue);
25 5
        }elseif($this->getProject()->getName()){
26 2
            $this->getProject()->setDirectoryPath(getcwd() . DIRECTORY_SEPARATOR . $this->getProject()->getName());
27 2
        }
28 5
        return $this->getProject()->getDirectoryPath() ? ITask::NO_ERROR_CODE : ITask::BLOCKING_ERROR_CODE;
29
    }
30
}
31