CommandLineHandler::setArgs()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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\Controllers;
11
12
abstract class CommandLineHandler
13
{
14
    public static $_args;
15
    abstract public static function handle();
16
17
    protected static function setArgs($path = null)
0 ignored issues
show
Unused Code introduced by
The parameter $path is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

17
    protected static function setArgs(/** @scrutinizer ignore-unused */ $path = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
18
    {
19
        if (!static::$_args) {
20
            static::$_args = $_SERVER['argv'];
21
        }
22
    }
23
    
24
    protected static function peekArgs()
25
    {
26
        if (!isset(static::$_args)) {
27
            static::setArgs();
28
        }
29
        return count(static::$_args) ? static::$_args[0] : false;
30
    }
31
32
    protected static function shiftArgs()
33
    {
34
        if (!isset(static::$_args)) {
35
            static::setArgs();
36
        }
37
        return array_shift(static::$_args);
38
    }
39
40
    protected static function getArgs()
41
    {
42
        if (!isset(static::$_args)) {
43
            static::setArgs();
44
        }
45
        return static::$_args;
46
    }
47
    
48
    protected static function unshiftArgs($string)
49
    {
50
        if (!isset(static::$_args)) {
51
            static::setArgs();
52
        }
53
        return array_unshift(static::$_args, $string);
54
    }
55
}
56