Conditions | 6 |
Paths | 5 |
Total Lines | 26 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
43 | function ts3RenderChannels(array $channels, array $clients, int $cid = null, int $depth = null):string{ |
||
44 | $str = ''; |
||
45 | |||
46 | foreach($channels as $channel){ |
||
47 | |||
48 | if($channel->pid === null){ |
||
49 | $depth = 0; |
||
50 | } |
||
51 | |||
52 | if($channel->pid === $cid){ |
||
53 | $str .= str_repeat(' ', $depth).$channel->channel_name."\n"; |
||
|
|||
54 | |||
55 | foreach($clients as $client){ |
||
56 | if($client->cid === $channel->cid){ |
||
57 | $str .= str_repeat(' ', $depth).' - '.$client->client_nickname."\n"; |
||
58 | } |
||
59 | } |
||
60 | |||
61 | // parse nested channels recursively |
||
62 | $str .= ts3RenderChannels($channels, $clients, $channel->cid, $depth); |
||
63 | } |
||
64 | |||
65 | $depth++; |
||
66 | } |
||
67 | |||
68 | return $str; |
||
69 | } |
||
70 |