Completed
Push — master ( c45fe6...da9ea2 )
by Rougin
06:15
created

RemoveCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 50
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isEnabled() 0 8 2
A configure() 0 6 1
A execute() 0 6 1
1
<?php
2
3
namespace Rougin\Combustor\Common\Commands;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
use Rougin\Combustor\Common\Tools;
9
use Rougin\Combustor\Commands\AbstractCommand;
10
11
/**
12
 * Remove Command
13
 *
14
 * Removes Doctrine/Wildfire library from CodeIgniter.
15
 * 
16
 * @package Combustor
17
 * @author  Rougin Royce Gutib <[email protected]>
18
 */
19
class RemoveCommand extends AbstractCommand
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $library = '';
25
26
    /**
27
     * Checks whether the command is enabled or not in the current environment.
28
     *
29
     * Override this to check for x or y and return false if the command can not
30
     * run properly under the current conditions.
31
     *
32
     * @return bool
33
     */
34
    public function isEnabled()
35
    {
36
        if ($this->library == 'doctrine') {
37
            return Tools::isDoctrineEnabled();
38
        }
39
40
        return Tools::isWildfireEnabled();
41
    }
42
43
    /**
44
     * Sets the configurations of the specified command.
45
     *
46
     * @return void
47
     */
48
    protected function configure()
49
    {
50
        $this
51
            ->setName('remove:' . $this->library)
52
            ->setDescription('Removes ' . ucfirst($this->library));
53
    }
54
55
    /**
56
     * Executes the command.
57
     * 
58
     * @param \Symfony\Component\Console\Input\InputInterface   $input
59
     * @param \Symfony\Component\Console\Output\OutputInterface $output
60
     * @return OutputInterface
61
     */
62
    protected function execute(InputInterface $input, OutputInterface $output)
63
    {
64
        $message = Tools::removeLibrary($this->library);
65
66
        return $output->writeln('<info>' . $message . '</info>');
67
    }
68
}
69