Enabling   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 27
ccs 15
cts 15
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 19 2
1
<?php
2
namespace Samurai\Module\Task;
3
4
use Samurai\Task\ITask;
5
use Samurai\Task\Task;
6
use SimilarText\Finder;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * Class Enabling
12
 * @package Samurai\Module\Task
13
 * @author Raphaël Lefebvre <[email protected]>
14
 */
15
class Enabling extends Task
16
{
17
    /**
18
     * @param InputInterface $input
19
     * @param OutputInterface $output
20
     * @return int|null
21
     */
22 3
    public function execute(InputInterface $input, OutputInterface $output)
23
    {
24 3
        $moduleName = $input->getArgument('name');
25 3
        if(!$this->getService('module_manager')->has($moduleName)){
26 1
            $textFinder = new Finder($moduleName, array_keys($this->getService('module_manager')->getAll()->getArrayCopy()));
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 125 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...
27 1
            $output->writeln(sprintf(
28 1
                '<error>Module "%s" not found! Did you mean "%s"?</error>',
29 1
                $moduleName,
30 1
                $textFinder->first()
31 1
            ));
32 1
            return ITask::BLOCKING_ERROR_CODE;
33
        }
34
35 2
        $module = $this->getService('module_manager')->get($moduleName);
36 3
        $module->setIsEnable($input->getArgument('action') === 'enable');
37 2
        $this->getService('module_manager')->modify($moduleName, $module);
38 2
        $output->writeln(sprintf('<info>Module "%s" modified</info>', $moduleName));
39 2
        return ITask::NO_ERROR_CODE;
40
    }
41
}
42