| Conditions | 7 |
| Paths | 8 |
| Total Lines | 57 |
| Code Lines | 42 |
| 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 |
||
| 111 | public function getVisitsData(Request $request) |
||
| 112 | {
|
||
| 113 | $date = $this->getDateOrPeriodFromRequest($request); |
||
| 114 | $period = $this->getDateOrPeriodFromRequest($request, true); |
||
| 115 | |||
| 116 | $imgDate = ''; |
||
| 117 | |||
| 118 | switch ($period) {
|
||
| 119 | case 'range': |
||
| 120 | $imgDate = $date; |
||
| 121 | break; |
||
| 122 | |||
| 123 | case 'week': |
||
| 124 | case 'month': |
||
| 125 | $value = $request->all()["value"]; |
||
| 126 | $range = array( |
||
| 127 | 'start' => $value["y2"] . '-' . $value["m2"] . '-' . $value["d2"], |
||
| 128 | 'end' => $value["y1"] . '-' . $value["m1"] . '-' . $value["d1"] |
||
| 129 | ); |
||
| 130 | $imgDate = $range['start'] . ',' . $range['end']; |
||
| 131 | break; |
||
| 132 | |||
| 133 | case 'day': |
||
| 134 | if ($date == 'today') {
|
||
| 135 | $imgDate = date('Y-m-d') . "," . date('Y-m-d', strtotime(date('Y-m-d') . " +2 day"));
|
||
| 136 | } |
||
| 137 | if ($date == 'yesterday') {
|
||
| 138 | $imgDate = date('Y-m-d') . "," . date('Y-m-d', strtotime(date('Y-m-d') . " +2 day"));
|
||
| 139 | } |
||
| 140 | break; |
||
| 141 | } |
||
| 142 | |||
| 143 | $matomoUrl = $this->matomoUrl; |
||
| 144 | $query_factory = QueryFactory::create($matomoUrl); |
||
| 145 | |||
| 146 | $query_factory |
||
| 147 | ->set('idSite', $this->siteId)
|
||
| 148 | ->set('token_auth', $this->authToken);
|
||
| 149 | |||
| 150 | $data = $query_factory->getQuery('API.get ')
|
||
| 151 | ->setParameter('date', $date)
|
||
| 152 | ->setParameter('period', $period)
|
||
| 153 | ->execute() |
||
| 154 | ->getResponse(); |
||
| 155 | |||
| 156 | return response()->json( |
||
| 157 | [ |
||
| 158 | 'visitimg' => $matomoUrl . '/index.php?forceView=1&viewDataTable=sparkline&module=API&action=get&idSite=' . $this->siteId . '&period=' . $period . '&date=' . $imgDate . '&segment=&showtitle=1&random=6179&columns=nb_visits%2Cnb_uniq_visitors&token_auth=' . $this->authToken, |
||
| 159 | 'avgvisitimg' => $matomoUrl . '/index.php?forceView=1&viewDataTable=sparkline&module=API&action=get&idSite=' . $this->siteId . '&period=' . $period . '&date=' . $imgDate . '&showtitle=1&random=6179&columns=avg_time_on_site&token_auth=' . $this->authToken, |
||
| 160 | 'bouncerateimg' => $matomoUrl . '/index.php?forceView=1&viewDataTable=sparkline&module=API&idSite=' . $this->siteId . '&period=' . $period . '&date=' . $imgDate . '&columns=bounce_rate&token_auth=' . $this->authToken, |
||
| 161 | 'actions_per_visit_img' => $matomoUrl . '/index.php?forceView=1&viewDataTable=sparkline&module=API&action=get&idSite=' . $this->siteId . '&period=' . $period . '&date=' . $imgDate . '&columns=nb_actions_per_visit&token_auth=' . $this->authToken, |
||
| 162 | 'pageviewimg' => $matomoUrl . '/index.php?forceView=1&viewDataTable=sparkline&module=API&action=get&idSite=' . $this->siteId . '&period=' . $period . '&date=' . $imgDate . '&columns=nb_pageviews%2Cnb_uniq_pageviews&token_auth=' . $this->authToken, |
||
| 163 | 'searchesandkeywordsimg' => $matomoUrl . '/index.php?forceView=1&viewDataTable=sparkline&module=API&action=get&idSite=' . $this->siteId . '&period=' . $period . '&date=' . $imgDate . '&columns=nb_searches%2Cnb_keywords&token_auth=' . $this->authToken, |
||
| 164 | 'downloadsimg' => $matomoUrl . '/index.php?forceView=1&viewDataTable=sparkline&module=API&action=get&idSite=' . $this->siteId . '&period=' . $period . '&date=' . $imgDate . '&columns=nb_downloads%2Cnb_uniq_downloads&token_auth=' . $this->authToken, |
||
| 165 | 'outlinksimg' => $matomoUrl . '/index.php?forceView=1&viewDataTable=sparkline&module=API&action=get&idSite=' . $this->siteId . '&period=' . $period . '&date=' . $imgDate . '&columns=nb_outlinks%2Cnb_uniq_outlinks&token_auth=' . $this->authToken, |
||
| 166 | 'maxactionsimg' => $matomoUrl . '/index.php?forceView=1&viewDataTable=sparkline&module=API&action=get&idSite=' . $this->siteId . '&period=' . $period . '&date=' . $imgDate . '&columns=max_actions&token_auth=' . $this->authToken, |
||
| 167 | 'data' => $data |
||
| 168 | ] |
||
| 236 |
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