| Conditions | 5 |
| Paths | 9 |
| Total Lines | 53 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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 declare(strict_types=1); |
||
| 119 | public function generateGraph(): bool |
||
| 120 | { |
||
| 121 | if (0 == $this->getVar('hasGraph')) { |
||
| 122 | return false; |
||
| 123 | } |
||
| 124 | |||
| 125 | if (0 == $this->getVar('hasResults')) { |
||
| 126 | $this->setResults(); |
||
| 127 | } |
||
| 128 | $aResults = $this->getVar('results'); |
||
| 129 | |||
| 130 | $graph = new Graph\Graph(500, 300); |
||
| 131 | $graph->title->Set($this->meta['name']); |
||
| 132 | $graph->setScale('textint'); |
||
| 133 | $graph->yaxis->scale->SetGrace(30); |
||
| 134 | |||
| 135 | //$graph->ygrid->Show(true,true); |
||
| 136 | $graph->ygrid->SetColor('gray', '[email protected]'); |
||
| 137 | |||
| 138 | // Setup graph colors |
||
| 139 | $graph->SetMarginColor('white'); |
||
| 140 | |||
| 141 | $i = 0; |
||
|
|
|||
| 142 | $data = []; |
||
| 143 | foreach ($aResults as $result) { |
||
| 144 | $data[0][] = $result['name']; |
||
| 145 | $data[1][] = $result['ticketsResponded']; |
||
| 146 | $data[2][] = $result['callsClosed']; |
||
| 147 | $data[3][] = $result['avgResponseTime']; |
||
| 148 | } |
||
| 149 | |||
| 150 | $datazero = [0, 0, 0, 0]; |
||
| 151 | |||
| 152 | // Create the "dummy" 0 bplot |
||
| 153 | $bplotzero = new Plot\BarPlot($datazero); |
||
| 154 | |||
| 155 | // Set names as x-axis label |
||
| 156 | $graph->xaxis->SetTickLabels($data[0]); |
||
| 157 | |||
| 158 | // Create the "Y" axis group |
||
| 159 | foreach ($data as $d) { |
||
| 160 | $ybplot1 = new Plot\BarPlot($d); |
||
| 161 | $ybplot1->value->Show(); |
||
| 162 | $ybplot = new Plot\GroupBarPlot([$ybplot1, $bplotzero]); |
||
| 163 | |||
| 164 | $graph->Add($ybplot); |
||
| 165 | } |
||
| 166 | |||
| 167 | // Set graph background image |
||
| 168 | $graph->SetBackgroundImage(\XHELP_IMAGE_PATH . '/graph_bg.jpg', BGIMG_FILLFRAME); |
||
| 169 | |||
| 170 | $graph->Stroke(); |
||
| 171 | return true; |
||
| 172 | } |
||
| 204 |