| Conditions | 10 | 
| Paths | 41 | 
| Total Lines | 64 | 
| 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  | 
            ||
| 80 | public function getByDate(ServerRequestInterface $request, ResponseInterface $response)  | 
            ||
| 81 |     { | 
            ||
| 82 |         try { | 
            ||
| 83 | $servers = $this->validateQueryStringArguments($_GET['servers'], 'servers');  | 
            ||
| 84 | $zones = $this->validateQueryStringArguments($_GET['zones'], 'zones');  | 
            ||
| 85 | $factions = $this->validateQueryStringArguments($_GET['factions'], 'factions');  | 
            ||
| 86 | $brackets = $this->validateQueryStringArguments($_GET['brackets'], 'brackets');  | 
            ||
| 87 | $dates = $this->validateQueryStringArguments($_GET['dates'], 'dates');  | 
            ||
| 88 |         } catch (InvalidArgumentException $e) { | 
            ||
| 89 | return $this->respondWithError($e->getMessage(), self::CODE_WRONG_ARGS);  | 
            ||
| 90 | }  | 
            ||
| 91 | |||
| 92 | $offset = (int) $_GET['offset'];  | 
            ||
| 93 | $limit = (int) $_GET['limit'];  | 
            ||
| 94 | |||
| 95 | // Set defaults if not supplied  | 
            ||
| 96 |         if (empty($offset) || ! is_numeric($offset)) { | 
            ||
| 97 | $offset = 0;  | 
            ||
| 98 | }  | 
            ||
| 99 | |||
| 100 |         if (empty($limit) || ! is_numeric($limit)) { | 
            ||
| 101 | $limit = 50;  | 
            ||
| 102 | }  | 
            ||
| 103 | |||
| 104 | // Check the date difference between two dates. we don't want to run queries for ALL OF ZE ALERTS NOW do we?!  | 
            ||
| 105 |         if (! empty($dates)) { | 
            ||
| 106 |             try { | 
            ||
| 107 | $this->getDateValidationUtility()->validateTimeDifference($dates, 180); // Allow half a year  | 
            ||
| 108 |             } catch (InvalidArgumentException $e) { | 
            ||
| 109 | return $this->respondWithError($e->getMessage(), self::CODE_WRONG_ARGS);  | 
            ||
| 110 | }  | 
            ||
| 111 | |||
| 112 | $limit = null;  | 
            ||
| 113 | }  | 
            ||
| 114 | |||
| 115 | $query = $this->repository->newQuery();  | 
            ||
| 116 | |||
| 117 | $brackets = $this->convertStringToArrayForAuraBinds($brackets);  | 
            ||
| 118 | $brackets[] = 'UNK';  | 
            ||
| 119 | |||
| 120 | $query->cols(['*']);  | 
            ||
| 121 |         $query->where('ResultServer IN (?)', $this->convertStringToArrayForAuraBinds($servers)); | 
            ||
| 122 |         $query->where('ResultAlertCont IN (?)', $this->convertStringToArrayForAuraBinds($zones)); | 
            ||
| 123 |         $query->where('ResultWinner IN (?)', $this->convertStringToArrayForAuraBinds($factions)); | 
            ||
| 124 |         $query->where('ResultTimeType IN (?)', $brackets); | 
            ||
| 125 | |||
| 126 |         if (! empty($dates)) { | 
            ||
| 127 | $this->addDateRangeWhereClause($dates, $query);  | 
            ||
| 128 | }  | 
            ||
| 129 | |||
| 130 | $query->orderBy(["ResultEndTime DESC"]);  | 
            ||
| 131 |         if ($limit) { | 
            ||
| 132 | $query->limit($limit);  | 
            ||
| 133 | }  | 
            ||
| 134 | $query->offset($offset);  | 
            ||
| 135 | |||
| 136 | $history = $this->repository->fireStatementAndReturn($query);  | 
            ||
| 137 | |||
| 138 | return $this->respond(  | 
            ||
| 139 | 'collection',  | 
            ||
| 140 | $history,  | 
            ||
| 141 | $this->transformer  | 
            ||
| 142 | );  | 
            ||
| 143 | }  | 
            ||
| 144 | }  | 
            ||
| 145 | 
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.