Completed
Push — master ( 4714ce...2b7987 )
by Rougin
04:26
created

AbstractCommand::isEnabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Rougin\Combustor\Commands;
4
5
use Twig_Environment;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Input\InputArgument;
9
10
use Rougin\Describe\Describe;
11
use Rougin\Combustor\Common\Tools;
12
13
/**
14
 * Abstract Command
15
 *
16
 * Extends the Symfony\Console\Command class with Twig's renderer.
17
 * 
18
 * @package Combustor
19
 * @author  Rougin Royce Gutib <[email protected]>
20
 */
21
abstract class AbstractCommand extends Command
22
{
23
    /**
24
     * @var string
25
     */
26
    protected $command = '';
27
28
    /**
29
     * @var \Rougin\Describe\Describe
30
     */
31
    protected $describe;
32
33
    /**
34
     * @var \Twig_Environment
35
     */
36
    protected $renderer;
37
38
    /**
39
     * @param \Twig_Environment         $renderer
40
     * @param \Rougin\Describe\Describe $describe
41
     */
42 57
    public function __construct(Describe $describe, Twig_Environment $renderer)
43
    {
44 57
        parent::__construct();
45
46 57
        $this->describe = $describe;
47 57
        $this->renderer = $renderer;
48 57
    }
49
50
    /**
51
     * Set the configurations of the specified command
52
     *
53
     * @return void
54
     */
55 30
    protected function configure()
56
    {
57 30
        $this->setName('create:' . $this->command)
58 30
            ->setDescription('Create a new ' . $this->command)
59 30
            ->addArgument(
60 30
                'name',
61 30
                InputArgument::REQUIRED,
62
                'Name of the table'
63 30
            )->addOption(
64 30
                'bootstrap',
65 30
                NULL,
66 30
                InputOption::VALUE_NONE,
67
                'Includes the Bootstrap CSS/JS Framework tags'
68 30
            )->addOption(
69 30
                'camel',
70 30
                NULL,
71 30
                InputOption::VALUE_NONE,
72
                'Uses the camel case naming convention'
73 30
            )->addOption(
74 30
                'keep',
75 30
                NULL,
76 30
                InputOption::VALUE_NONE,
77
                'Keeps the name to be used'
78 30
            );
79
80 30
        if ($this->command == 'controller') {
81 24
            $this->addOption(
82 24
                'lowercase',
83 24
                null,
84 24
                InputOption::VALUE_NONE,
85
                'Keeps the first character of the name to lowercase'
86 24
            );
87 24
        }
88 30
    }
89
90
    /**
91
     * Checks whether the command is enabled or not in the current environment.
92
     *
93
     * @return bool
94
     */
95 6
    public function isEnabled()
96
    {
97 6
        return Tools::isCommandEnabled();
98
    }
99
}
100