| Conditions | 16 |
| Paths | 29 |
| Total Lines | 83 |
| Code Lines | 52 |
| 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 |
||
| 22 | public function handle($mixed): void |
||
| 23 | { |
||
| 24 | $chart = $this->em->getRepository('VideoGamesRecords\CoreBundle\Entity\Chart')->find($mixed); |
||
| 25 | if (null === $chart) { |
||
| 26 | return; |
||
| 27 | } |
||
| 28 | |||
| 29 | $this->groups[$chart->getGroup()->getId()] = $chart->getGroup(); |
||
| 30 | $this->games[$chart->getGroup()->getGame()->getId()] = $chart->getGroup()->getGame(); |
||
| 31 | |||
| 32 | //----- delete |
||
| 33 | $query = $this->em->createQuery('DELETE VideoGamesRecords\CoreBundle\Entity\TeamChart tc WHERE tc.chart = :chart'); |
||
| 34 | $query->setParameter('chart', $chart); |
||
| 35 | $query->execute(); |
||
| 36 | |||
| 37 | $query = $this->em->createQuery(" |
||
| 38 | SELECT pc |
||
| 39 | FROM VideoGamesRecords\CoreBundle\Entity\PlayerChart pc |
||
| 40 | JOIN pc.player p |
||
| 41 | JOIN p.team t |
||
| 42 | WHERE pc.chart = :chart |
||
| 43 | ORDER BY pc.pointChart DESC"); |
||
| 44 | |||
| 45 | $query->setParameter('chart', $chart); |
||
| 46 | $result = $query->getResult(); |
||
| 47 | |||
| 48 | $list = array(); |
||
| 49 | foreach ($result as $playerChart) { |
||
| 50 | $team = $playerChart->getPlayer()->getTeam(); |
||
| 51 | $this->teams[$team->getId()] = $team; |
||
| 52 | |||
| 53 | $idTeam = $team->getId(); |
||
| 54 | if (!isset($list[$idTeam])) { |
||
| 55 | $list[$idTeam] = [ |
||
| 56 | 'idTeam' => $playerChart->getPlayer()->getTeam()->getId(), |
||
| 57 | 'nbPlayer' => 1, |
||
| 58 | 'pointChart' => $playerChart->getPointChart(), |
||
| 59 | 'chartRank0' => 0, |
||
| 60 | 'chartRank1' => 0, |
||
| 61 | 'chartRank2' => 0, |
||
| 62 | 'chartRank3' => 0, |
||
| 63 | ]; |
||
| 64 | } elseif ($list[$idTeam]['nbPlayer'] < 5) { |
||
| 65 | $list[$idTeam]['nbPlayer'] += 1; |
||
| 66 | $list[$idTeam]['pointChart'] += $playerChart->getPointChart(); |
||
| 67 | } |
||
| 68 | } |
||
| 69 | |||
| 70 | //----- add some data |
||
| 71 | $list = array_values($list); |
||
| 72 | $list = Ranking::order($list, ['pointChart' => SORT_DESC]); |
||
| 73 | $list = Ranking::addRank($list, 'rankPointChart', ['pointChart'], true); |
||
| 74 | |||
| 75 | $normalizer = new ObjectNormalizer(); |
||
| 76 | $serializer = new Serializer([$normalizer]); |
||
| 77 | |||
| 78 | $nbTeam = count($list); |
||
| 79 | |||
| 80 | foreach ($list as $row) { |
||
| 81 | //----- add medals |
||
| 82 | if ($row['rankPointChart'] == 1 && $row['nbEqual'] == 1 && $nbTeam > 1) { |
||
| 83 | $row['chartRank0'] = 1; |
||
| 84 | $row['chartRank1'] = 1; |
||
| 85 | } elseif ($row['rankPointChart'] == 1 && $row['nbEqual'] == 1 && $nbTeam == 1) { |
||
| 86 | $row['chartRank1'] = 1; |
||
| 87 | } elseif ($row['rankPointChart'] == 1 && $row['nbEqual'] > 1) { |
||
| 88 | $row['chartRank1'] = 1; |
||
| 89 | } elseif ($row['rankPointChart'] == 2) { |
||
| 90 | $row['chartRank2'] = 1; |
||
| 91 | } elseif ($row['rankPointChart'] == 3) { |
||
| 92 | $row['chartRank3'] = 1; |
||
| 93 | } |
||
| 94 | |||
| 95 | $teamChart = $serializer->denormalize( |
||
| 96 | $row, 'VideoGamesRecords\CoreBundle\Entity\TeamChart' |
||
| 97 | ); |
||
| 98 | $teamChart->setTeam($this->em->getReference('VideoGamesRecords\CoreBundle\Entity\Team', $row['idTeam'])); |
||
| 99 | $teamChart->setChart($chart); |
||
| 100 | |||
| 101 | $this->em->persist($teamChart); |
||
| 102 | } |
||
| 103 | |||
| 104 | $this->em->flush(); |
||
| 105 | } |
||
| 122 |
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