Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
46 | private function getIP() { |
||
|
|||
47 | $os = strtolower(PHP_OS); |
||
48 | switch ($os) { |
||
49 | case 'linux': //Linux |
||
50 | preg_match_all('/inet addr: ?([^ ]+)/', `ifconfig |grep "inet " |grep -v "127.0.0.1"`, $ips); |
||
51 | break; |
||
52 | case 'darwin': //OSX |
||
53 | preg_match_all('/inet ?([^ ]+)/', `ifconfig -au |grep "inet " |grep -v "127.0.0.1"`, $ips); |
||
54 | break; |
||
55 | default: |
||
56 | throw new \Exception("Unsupported OS: " . $os); |
||
57 | break; |
||
58 | } |
||
59 | return $ips[1][0]; |
||
60 | } |
||
61 | } |
||
62 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.