BootstrapImportation   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 14 3
A getOptions() 0 6 1
1
<?php
2
namespace Samurai\Project\Task;
3
4
use Samurai\Task\ITask;
5
use Samurai\Task\Task;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class BootstrapImportation
11
 * @package Samurai\Project\Task
12
 * @author Raphaël Lefebvre <[email protected]>
13
 */
14
class BootstrapImportation extends Task
15
{
16
    /**
17
     * @param InputInterface $input
18
     * @param OutputInterface $output
19
     * @return int
20
     */
21 5
    public function execute(InputInterface $input, OutputInterface $output)
22
    {
23 5
        if(!$this->getService('project')->getBootstrap()){
24 1
           throw new \InvalidArgumentException('The bootstrap of the project is not defined');
25
        }
26
27 4
        $output->writeln(sprintf(
28 4
            '<info>Installing project %s from %s</info>',
29 4
            $this->getService('project')->getName(),
30 4
            $this->getService('project')->getBootstrap()->getPackage()
31 4
        ));
32
33 4
        return $this->getService('composer')->createProject($this->getService('project'), $this->getOptions()) === 0 ? ITask::NO_ERROR_CODE : ITask::BLOCKING_ERROR_CODE;
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 169 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
34
    }
35
36
    /**
37
     * @return array
38
     */
39 4
    private function getOptions()
40
    {
41 4
        return array_filter([
42 4
            'repository-url' => $this->getService('project')->getBootstrap()->getSource()
43 4
        ]);
44
    }
45
}
46