Command::handle()   C
last analyzed

Complexity

Conditions 11
Paths 18

Size

Total Lines 41
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 11
eloc 26
nc 18
nop 0
dl 0
loc 41
rs 5.2653
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
 * This file is part of the Divergence package.
4
 *
5
 * (c) Henry Paradiz <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Divergence\CLI;
11
12
use Divergence\CLI\Env;
13
use \League\CLImate\CLImate;
14
use Divergence\CLI\Controllers\Commands\Basics;
15
use Divergence\CLI\Controllers\Commands\Config;
16
use Divergence\CLI\Controllers\Commands\Tester;
17
use Divergence\CLI\Controllers\CommandLineHandler;
18
19
use Divergence\CLI\Controllers\Commands\Initialize;
20
21
class Command extends CommandLineHandler
22
{
23
    public static $climate; // instance of \League\CLImate\CLImate;
24
25
    public static function getClimate()
26
    {
27
        return static::$climate;
28
    }
29
30
    public static function handle()
31
    {
32
        Env::getEnvironment();
33
34
        Env::$me = static::shiftArgs();
35
36
        static::$climate = new CLImate();
37
        //static::$climate->style->addCommand('orange', '38;5;208' /*'38;5;208'*/);
38
        //static::$climate->orange('test'); exit;
39
40
        switch ($action = static::shiftArgs()) {
0 ignored issues
show
Unused Code introduced by
The assignment to $action is dead and can be removed.
Loading history...
41
            case 'init':
42
                Initialize::init();
43
            break;
44
45
            case 'status':
46
                Basics::status();
47
            break;
48
49
            case 'config':
50
                Config::handle();
51
52
                // no break
53
            case 'build':
54
                // Divergence\Controllers\Builder::handle();
55
            break;
56
57
            case 'test':
58
                Tester::handle();
59
            break;
60
61
            case '-v':
62
            case '--version':
63
                Basics::version();
64
            break;
65
66
            case '--help':
67
            case '-h':
68
            case 'help':
69
            default:
70
                Basics::usage();
71
        }
72
    }
73
}
74