| 1 | <?php |
||
| 6 | class Cli extends Request |
||
| 7 | { |
||
| 8 | const SHORT = 'SHORT'; |
||
| 9 | const LONG = 'LONG'; |
||
| 10 | |||
| 11 | private $opt = array(self::SHORT => '', self::LONG => array('route:')); |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @param string $short |
||
| 15 | * @param array $long |
||
| 16 | * @return $this |
||
| 17 | */ |
||
| 18 | 1 | public function defineOpt($short = '', array $long = array()) |
|
| 27 | |||
| 28 | /** |
||
| 29 | * Retrieve defined opt |
||
| 30 | * @return array |
||
| 31 | */ |
||
| 32 | 1 | public function getDefinedOpt() |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @param string $name |
||
| 39 | * @param mixed $defaultValue |
||
| 40 | * @return string|mixed |
||
| 41 | */ |
||
| 42 | 1 | public function get($name, $defaultValue = null) |
|
| 47 | |||
| 48 | /** |
||
| 49 | * @return array |
||
| 50 | */ |
||
| 51 | 1 | public function getOpt() |
|
| 55 | |||
| 56 | /** |
||
| 57 | * @param string $short |
||
| 58 | * @param array $long |
||
| 59 | * @return array |
||
| 60 | * @codeCoverageIgnore |
||
| 61 | */ |
||
| 62 | protected function phpGetOpt($short, array $long = array()) |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @param string $name |
||
| 69 | * @return bool |
||
| 70 | */ |
||
| 71 | 1 | public function has($name) |
|
| 75 | |||
| 76 | /** |
||
| 77 | * @param bool|false $withQuerySting |
||
| 78 | * @return string |
||
| 79 | */ |
||
| 80 | 2 | public function getRequestUri($withQuerySting = false) |
|
| 90 | } |
||
| 91 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: