| Conditions | 10 |
| Paths | 76 |
| Total Lines | 82 |
| Code Lines | 64 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 16 | public function epormas() |
||
| 17 | { |
||
| 18 | //Pegawai Epormas |
||
| 19 | $grafikepormascounter = DB::table('epormas_counter') |
||
| 20 | ->select('tahun','bulan','city_id', DB::raw('SUM(count) as count')) |
||
| 21 | ->whereNull('deleted_at')->groupBy('tahun','bulan','city_id')->orderBy('bulan')->get(); |
||
| 22 | $grafiktahunepormascounter = DB::table('epormas_counter') |
||
| 23 | ->select('tahun', DB::raw('SUM(count) as count')) |
||
| 24 | ->whereNull('deleted_at')->groupBy('tahun')->orderBy('tahun')->get(); |
||
| 25 | |||
| 26 | $namaBulan = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
||
| 27 | $namaBulans = array('Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'); |
||
| 28 | $city = EpormasCity::all(); |
||
| 29 | $category = EpormasCategory::all(); |
||
| 30 | $countcity = count($city); |
||
| 31 | $countcategory = count($category); |
||
| 32 | |||
| 33 | $countgrafikepormascounter = count($grafikepormascounter); |
||
| 34 | $countgrafiktahunepormascounter = count($grafiktahunepormascounter); |
||
| 35 | $datagrafikepormascounter = []; |
||
| 36 | $datagrafiktahunepormascounter = []; |
||
| 37 | $datagrafikcountepormascounter = []; |
||
| 38 | $datagrafiktotalepormascounter = []; |
||
| 39 | $grafikcountepormascounter = []; |
||
| 40 | $grafikbulanepormascounter = []; |
||
| 41 | $grafiktotalepormascounter = []; |
||
| 42 | $grafikpieepormascounter = []; |
||
| 43 | for($q=0; $q<$countgrafiktahunepormascounter; $q++){ |
||
| 44 | $tahungrafikepormascounter = $grafiktahunepormascounter[$q]->tahun; |
||
| 45 | $gcountepormascounter = (int)$grafiktahunepormascounter[$q]->count; |
||
| 46 | $totaldataepormascounter = $gcountepormascounter; |
||
| 47 | array_push($datagrafiktahunepormascounter,$tahungrafikepormascounter); |
||
| 48 | array_push($datagrafikcountepormascounter,$gcountepormascounter); |
||
| 49 | array_push($datagrafiktotalepormascounter,$totaldataepormascounter); |
||
| 50 | |||
| 51 | for($kota=1; $kota<=$countcity; $kota++){ |
||
| 52 | for ($index=0; $index<12; $index++) { |
||
| 53 | $grafikcountepormascounter[$q][$kota][$index] = 0; |
||
| 54 | $grafikbulanepormascounter[$q][$kota][$index] = 0; |
||
| 55 | $grafiktotalepormascounter[$q][$kota][$index] = 0; |
||
| 56 | $grafikpieepormascounter[$q][$kota][$index] = ['value'=>0,'name'=>$namaBulan[$index]]; |
||
| 57 | $totaldatagrafikepormascounter[$q][$index] = 0; |
||
| 58 | } |
||
| 59 | } |
||
| 60 | for($r=0; $r<$countgrafikepormascounter; $r++){ |
||
| 61 | $tahunsepormascounter = $grafikepormascounter[$r]->tahun; |
||
| 62 | $bulansepormascounter = $grafikepormascounter[$r]->bulan; |
||
| 63 | $city_id = $grafikepormascounter[$r]->city_id; |
||
| 64 | if($bulansepormascounter < 10){ |
||
| 65 | $bulanepormascounter = substr($bulansepormascounter,1); |
||
| 66 | }else { |
||
| 67 | $bulanepormascounter = $bulansepormascounter; |
||
| 68 | } |
||
| 69 | if($tahungrafikepormascounter == $tahunsepormascounter){ |
||
| 70 | $totaldatagrafikepormascounter[$q][$bulanepormascounter-1] += $grafikepormascounter[$r]->count; |
||
| 71 | } |
||
| 72 | } |
||
| 73 | for($r=0; $r<$countgrafikepormascounter; $r++){ |
||
| 74 | $tahunsepormascounter = $grafikepormascounter[$r]->tahun; |
||
| 75 | $bulansepormascounter = $grafikepormascounter[$r]->bulan; |
||
| 76 | $city_id = $grafikepormascounter[$r]->city_id; |
||
| 77 | if($bulansepormascounter < 10){ |
||
| 78 | $bulanepormascounter = substr($bulansepormascounter,1); |
||
| 79 | }else { |
||
| 80 | $bulanepormascounter = $bulansepormascounter; |
||
| 81 | } |
||
| 82 | if($tahungrafikepormascounter == $tahunsepormascounter){ |
||
| 83 | $grafikcountepormascounter[$q][$city_id][$bulanepormascounter-1] = (int)$grafikepormascounter[$r]->count; |
||
| 84 | $grafikbulanepormascounter[$q][$city_id][$bulanepormascounter-1] = $grafikepormascounter[$r]->bulan; |
||
| 85 | $totaldatagrafikepormascounters = $totaldatagrafikepormascounter[$q][$bulanepormascounter-1]; |
||
| 86 | $grafiktotalepormascounter[$q][$city_id][$bulanepormascounter-1] = $totaldatagrafikepormascounters; |
||
| 87 | $grafikpieepormascounter[$q][$city_id][$bulanepormascounter-1] = ['value'=>$totaldatagrafikepormascounters,'name'=>$namaBulan[$bulanepormascounter-1]]; |
||
| 88 | } |
||
| 89 | } |
||
| 90 | } |
||
| 91 | $chartgrafikcountepormascounter = ['chartdata'=>$grafikcountepormascounter]; |
||
| 92 | $datagrafikepormascounter = ['count'=>$grafikcountepormascounter, 'bulan'=>$grafikbulanepormascounter, 'namabulan'=>$namaBulan, 'namabulans'=>$namaBulans, 'kategori'=>$category, 'kota'=>$city, 'total'=>$grafiktotalepormascounter, 'datatahun'=>['tahun'=>$datagrafiktahunepormascounter, 'count'=>$datagrafikcountepormascounter, 'totaldata'=>$datagrafiktotalepormascounter], 'datapie'=>$grafikpieepormascounter, 'seriesdata'=>[$chartgrafikcountepormascounter]]; |
||
| 93 | //end Pegawai Epormas |
||
| 94 | |||
| 95 | return Response::json(array( |
||
| 96 | //Jumlah Penduduk |
||
| 97 | 'datachartepormascounter' => $datagrafikepormascounter |
||
| 98 | //end Jumlah Penduduk |
||
| 102 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths