| Conditions | 7 | 
| Paths | 48 | 
| Total Lines | 67 | 
| Code Lines | 44 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 5 | ||
| Bugs | 1 | Features | 2 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 70 | public function getSwooleMetrics()  | 
            ||
| 71 |     { | 
            ||
| 72 | /**@var \Swoole\Http\Server $swoole */  | 
            ||
| 73 |         $swoole = app('swoole'); | 
            ||
| 74 | $stats = $swoole->stats();  | 
            ||
| 75 | // Get worker_num/task_worker_num from setting for the old Swoole.  | 
            ||
| 76 | $setting = $swoole->setting;  | 
            ||
| 77 |         if (!isset($stats['worker_num'])) { | 
            ||
| 78 | $stats['worker_num'] = $setting['worker_num'];  | 
            ||
| 79 | }  | 
            ||
| 80 |         if (!isset($stats['task_worker_num'])) { | 
            ||
| 81 | $stats['task_worker_num'] = isset($setting['task_worker_num']) ? $setting['task_worker_num'] : 0;  | 
            ||
| 82 | }  | 
            ||
| 83 | return [  | 
            ||
| 84 | [  | 
            ||
| 85 | 'name' => 'swoole_start_time',  | 
            ||
| 86 | 'help' => '',  | 
            ||
| 87 | 'type' => 'gauge',  | 
            ||
| 88 | 'value' => $stats['start_time'],  | 
            ||
| 89 | ],  | 
            ||
| 90 | [  | 
            ||
| 91 | 'name' => 'swoole_connection_num',  | 
            ||
| 92 | 'help' => '',  | 
            ||
| 93 | 'type' => 'gauge',  | 
            ||
| 94 | 'value' => $stats['connection_num'],  | 
            ||
| 95 | ],  | 
            ||
| 96 | [  | 
            ||
| 97 | 'name' => 'swoole_request_count',  | 
            ||
| 98 | 'help' => '',  | 
            ||
| 99 | 'type' => 'gauge',  | 
            ||
| 100 | 'value' => $stats['request_count'],  | 
            ||
| 101 | ],  | 
            ||
| 102 | [  | 
            ||
| 103 | 'name' => 'swoole_worker_num',  | 
            ||
| 104 | 'help' => '',  | 
            ||
| 105 | 'type' => 'gauge',  | 
            ||
| 106 | 'value' => $stats['worker_num'],  | 
            ||
| 107 | ],  | 
            ||
| 108 | [  | 
            ||
| 109 | 'name' => 'swoole_idle_worker_num',  | 
            ||
| 110 | 'help' => '',  | 
            ||
| 111 | 'type' => 'gauge',  | 
            ||
| 112 | 'value' => isset($stats['idle_worker_num']) ? $stats['idle_worker_num'] : 0,  | 
            ||
| 113 | ],  | 
            ||
| 114 | [  | 
            ||
| 115 | 'name' => 'swoole_task_worker_num',  | 
            ||
| 116 | 'help' => '',  | 
            ||
| 117 | 'type' => 'gauge',  | 
            ||
| 118 | 'value' => $stats['task_worker_num'],  | 
            ||
| 119 | ],  | 
            ||
| 120 | [  | 
            ||
| 121 | 'name' => 'swoole_task_idle_worker_num',  | 
            ||
| 122 | 'help' => '',  | 
            ||
| 123 | 'type' => 'gauge',  | 
            ||
| 124 | 'value' => isset($stats['task_idle_worker_num']) ? $stats['task_idle_worker_num'] : 0,  | 
            ||
| 125 | ],  | 
            ||
| 126 | [  | 
            ||
| 127 | 'name' => 'swoole_tasking_num',  | 
            ||
| 128 | 'help' => '',  | 
            ||
| 129 | 'type' => 'gauge',  | 
            ||
| 130 | 'value' => $stats['tasking_num'],  | 
            ||
| 131 | ],  | 
            ||
| 132 | [  | 
            ||
| 133 | 'name' => 'swoole_coroutine_num',  | 
            ||
| 134 | 'help' => '',  | 
            ||
| 135 | 'type' => 'gauge',  | 
            ||
| 136 | 'value' => isset($stats['coroutine_num']) ? $stats['coroutine_num'] : 0,  | 
            ||
| 137 | ],  | 
            ||
| 200 | }  |