| Conditions | 10 |
| Paths | 56 |
| Total Lines | 77 |
| Code Lines | 40 |
| 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 |
||
| 55 | public function ReportingApi(Request $request) |
||
| 56 | {
|
||
| 57 | $data = $request->all(); |
||
| 58 | $matomoUrl = ChuckSite::getSetting('integrations.matomo-site-url') !== null ? ChuckSite::getSetting('integrations.matomo-site-url') : config('chuckcms.analytics.matomoURL');
|
||
| 59 | $query_factory = QueryFactory::create($matomoUrl); |
||
| 60 | $query_factory |
||
| 61 | ->set('idSite', $this->siteId)
|
||
| 62 | ->set('token_auth', $this->authToken);
|
||
| 63 | |||
| 64 | $date = 'today'; |
||
| 65 | $period = 'day'; |
||
| 66 | |||
| 67 | if($data["value"]["range"] !== "Today" || $data["value"]["range"] !== "Yesterday"){
|
||
| 68 | if(isset($data["value"]["y2"],$data["value"]["m2"],$data["value"]["d2"])){
|
||
| 69 | $now = \Carbon\Carbon::now(); |
||
| 70 | $startdate = \Carbon\Carbon::createFromFormat('Y-m-d', $data["value"]["y2"].'-'.$data["value"]["m2"].'-'.$data["value"]["d2"]);
|
||
| 71 | $enddate = \Carbon\Carbon::createFromFormat('Y-m-d',$data["value"]["y1"].'-'.$data["value"]["m1"].'-'.$data["value"]["d1"]);
|
||
| 72 | $checkforrange = $now->diffInDays($enddate); |
||
| 73 | $diff = $startdate->diffInDays($enddate); |
||
| 74 | if($checkforrange !== 0){
|
||
| 75 | $period = 'range'; |
||
| 76 | $date = $data["value"]["y2"].'-'.$data["value"]["m2"].'-'.$data["value"]["d2"].','.$data["value"]["y1"].'-'.$data["value"]["m1"].'-'.$data["value"]["d1"]; |
||
| 77 | }else{
|
||
| 78 | if($diff == 6){
|
||
| 79 | $period = 'week'; |
||
| 80 | $date = 'last7'; |
||
| 81 | } |
||
| 82 | if($diff == 29){
|
||
| 83 | $period = 'month'; |
||
| 84 | $date = 'last30'; |
||
| 85 | } |
||
| 86 | } |
||
| 87 | } |
||
| 88 | } |
||
| 89 | if($data["value"]["range"] == "Today"){
|
||
| 90 | $date = 'today'; |
||
| 91 | $period = 'day'; |
||
| 92 | } |
||
| 93 | if($data["value"]["range"] == "Yesterday"){
|
||
| 94 | $date = 'yesterday'; |
||
| 95 | $period = 'day'; |
||
| 96 | } |
||
| 97 | |||
| 98 | // $visitsSummary = $query_factory->getQuery('VisitsSummary.get')
|
||
| 99 | // ->setParameter('date', $date)
|
||
| 100 | // ->setParameter('period', 'day')
|
||
| 101 | // ->execute() |
||
| 102 | // ->getResponse(); |
||
| 103 | |||
| 104 | |||
| 105 | $lastVisitsDetails = $query_factory->getQuery('Live.getLastVisitsDetails')
|
||
| 106 | ->setParameter('date', $date)
|
||
| 107 | ->setParameter('period', $period)
|
||
| 108 | ->setParameter('filter_limit', -1)
|
||
| 109 | ->execute() |
||
| 110 | ->getResponse(); |
||
| 111 | |||
| 112 | |||
| 113 | // $heatMaps = $query_factory->getQuery('HeatmapSessionRecording.getHeatmaps')
|
||
| 114 | // ->execute() |
||
| 115 | // ->getResponse(); |
||
| 116 | |||
| 117 | // $heatMap = array(); |
||
| 118 | // foreach($heatMaps as $key=>$value) |
||
| 119 | // {
|
||
| 120 | |||
| 121 | // $heatMap[] = $query_factory->getQuery('HeatmapSessionRecording.getHeatmap')
|
||
| 122 | // ->setParameter('idSiteHsr', $value->idsitehsr)
|
||
| 123 | // ->execute() |
||
| 124 | // ->getResponse(); |
||
| 125 | |||
| 126 | // } |
||
| 127 | |||
| 128 | |||
| 129 | return response()->json([ |
||
| 130 | 'success'=>'success', |
||
| 131 | 'lastVisitsDetails' => $lastVisitsDetails, |
||
| 132 | ]); |
||
| 254 | } |
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