| Conditions | 10 |
| Paths | 512 |
| Total Lines | 58 |
| Code Lines | 28 |
| 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 |
||
| 25 | public function SearchPlayersManual($league, $first = "NA", $last = "NA", $team = "NA", $position = "NA") { |
||
| 26 | //Approach taken from: http://stackoverflow.com/a/4540085/324527 |
||
| 27 | |||
| 28 | $searchSql = "SELECT * FROM pro_players WHERE league = :league"; |
||
| 29 | |||
| 30 | $searchParams = array(); |
||
| 31 | $regularParams = array(); |
||
| 32 | |||
| 33 | if ($first != "NA") { |
||
| 34 | $searchParams['first_name'] = $first; |
||
| 35 | } |
||
| 36 | |||
| 37 | if ($last != "NA") { |
||
| 38 | $searchParams['last_name'] = $last; |
||
| 39 | } |
||
| 40 | |||
| 41 | if ($team != "NA") { |
||
| 42 | $regularParams['team'] = $team; |
||
| 43 | } |
||
| 44 | |||
| 45 | if ($position != "NA") { |
||
| 46 | $regularParams['position'] = $position; |
||
| 47 | } |
||
| 48 | |||
| 49 | //Finish building PDO SQL with dynamic values: |
||
| 50 | foreach ($searchParams as $key => $value) { |
||
| 51 | $searchSql .= sprintf(' AND %s LIKE :%s', $key, $key); |
||
| 52 | } |
||
| 53 | |||
| 54 | foreach ($regularParams as $key => $value) { |
||
| 55 | $searchSql .= sprintf(' AND %s = :%s', $key, $key); |
||
| 56 | } |
||
| 57 | |||
| 58 | //Limit the amount of searches to just 15 to cut down on unnecessary network traffic |
||
| 59 | $searchSql .= ' LIMIT 15'; |
||
| 60 | |||
| 61 | $stmt = $this->app['db']->prepare($searchSql); |
||
| 62 | $stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\ProPlayer'); |
||
| 63 | $stmt->bindValue(':league', $league); |
||
| 64 | |||
| 65 | //Assign values to those parameters: |
||
| 66 | foreach ($searchParams as $key => $value) { |
||
| 67 | $stmt->bindValue(':' . $key, "%" . $value . "%"); |
||
| 68 | } |
||
| 69 | |||
| 70 | foreach ($regularParams as $key => $value) { |
||
| 71 | $stmt->bindValue(':' . $key, $value); |
||
| 72 | } |
||
| 73 | |||
| 74 | $stmt->execute(); |
||
| 75 | |||
| 76 | $foundPlayers = array(); |
||
| 77 | |||
| 78 | while ($newPlayer = $stmt->fetch()) { |
||
| 79 | $foundPlayers[] = $newPlayer; |
||
| 80 | } |
||
| 81 | |||
| 82 | return array_slice($foundPlayers, 0, 15); |
||
| 83 | } |
||
| 169 | } |
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