| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 43 | 4 | public function getStream(string $string) |
|
| 44 | { |
||
| 45 | 4 | $stream = $this->stream; |
|
| 46 | 4 | rewind($stream); |
|
| 47 | 4 | $hash = array_keys($this->streams); |
|
| 48 | 4 | $regex = sprintf('/(%s)/', implode('|', $hash)); |
|
| 49 | 4 | preg_match_all($regex, $string, $match, PREG_SET_ORDER); |
|
| 50 | 4 | $list = $this->collect($match); |
|
|
|
|||
| 51 | 4 | $bodies = preg_split($regex, $string); |
|
| 52 | 4 | foreach ($bodies as $body) { |
|
| 53 | 4 | fwrite($stream, $body); |
|
| 54 | 4 | $index = array_shift($list); |
|
| 55 | 4 | if (isset($this->streams[$index])) { |
|
| 56 | 2 | $popStream = $this->streams[$index]; |
|
| 57 | 2 | rewind($popStream); |
|
| 58 | 4 | stream_copy_to_stream($popStream, $stream); |
|
| 59 | } |
||
| 60 | } |
||
| 61 | |||
| 62 | 4 | return $stream; |
|
| 63 | } |
||
| 64 | |||
| 75 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.