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
|
|||
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 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.