| Conditions | 5 |
| Paths | 7 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | 2 | public function read(Socket $socket) |
|
| 24 | { |
||
| 25 | 2 | $characterEtb = null; |
|
| 26 | 2 | $buffer = ''; |
|
| 27 | 2 | while (true) { |
|
| 28 | 2 | $character = $socket->read(1); |
|
| 29 | |||
| 30 | // the character we terminate on depends on the first character in the response |
||
| 31 | 2 | if (!isset($characterEtb)) { |
|
| 32 | 2 | if ($character == "\x01") { |
|
| 33 | 1 | $characterEtb = "\x17"; |
|
| 34 | 1 | } else { |
|
| 35 | 1 | $characterEtb = "\n"; |
|
| 36 | } |
||
| 37 | 2 | } |
|
| 38 | |||
| 39 | 2 | $buffer .= $character; |
|
| 40 | 2 | if ($character == $characterEtb) { |
|
| 41 | 2 | break; |
|
| 42 | } |
||
| 43 | 2 | } |
|
| 44 | |||
| 45 | 2 | return trim($buffer, "\x01\x17"); |
|
| 46 | } |
||
| 48 |