| Conditions | 4 |
| Paths | 5 |
| Total Lines | 64 |
| Code Lines | 24 |
| 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 |
||
| 27 | public function handle($mixed): void |
||
| 28 | { |
||
| 29 | $serie = $this->em->getRepository('VideoGamesRecords\CoreBundle\Entity\Serie')->find($mixed); |
||
| 30 | if (null === $serie) { |
||
| 31 | return; |
||
| 32 | } |
||
| 33 | |||
| 34 | // Delete old data |
||
| 35 | $query = $this->em->createQuery('DELETE VideoGamesRecords\CoreBundle\Entity\PlayerSerie us WHERE us.serie = :serie'); |
||
| 36 | $query->setParameter('serie', $serie); |
||
| 37 | $query->execute(); |
||
| 38 | |||
| 39 | // Select data |
||
| 40 | $query = $this->em->createQuery(" |
||
| 41 | SELECT |
||
| 42 | p.id as idPlayer, |
||
| 43 | '' as rankPointChart, |
||
| 44 | '' as rankMedal, |
||
| 45 | SUM(pg.chartRank0) as chartRank0, |
||
| 46 | SUM(pg.chartRank1) as chartRank1, |
||
| 47 | SUM(pg.chartRank2) as chartRank2, |
||
| 48 | SUM(pg.chartRank3) as chartRank3, |
||
| 49 | SUM(pg.chartRank4) as chartRank4, |
||
| 50 | SUM(pg.chartRank5) as chartRank5, |
||
| 51 | SUM(pg.pointGame) as pointGame, |
||
| 52 | SUM(pg.pointChart) as pointChart, |
||
| 53 | SUM(pg.pointChartWithoutDlc) as pointChartWithoutDlc, |
||
| 54 | SUM(pg.nbChart) as nbChart, |
||
| 55 | SUM(pg.nbChartWithoutDlc) as nbChartWithoutDlc, |
||
| 56 | SUM(pg.nbChartProven) as nbChartProven, |
||
| 57 | SUM(pg.nbChartProvenWithoutDlc) as nbChartProvenWithoutDlc, |
||
| 58 | COUNT(DISTINCT pg.game) as nbGame |
||
| 59 | FROM VideoGamesRecords\CoreBundle\Entity\PlayerGame pg |
||
| 60 | JOIN pg.game g |
||
| 61 | JOIN pg.player p |
||
| 62 | WHERE g.serie = :serie |
||
| 63 | GROUP BY p.id |
||
| 64 | ORDER BY pointChart DESC"); |
||
| 65 | |||
| 66 | $query->setParameter('serie', $serie); |
||
| 67 | $result = $query->getResult(); |
||
| 68 | |||
| 69 | $list = []; |
||
| 70 | foreach ($result as $row) { |
||
| 71 | $list[] = $row; |
||
| 72 | } |
||
| 73 | |||
| 74 | $list = Ranking::addRank($list, 'rankPointChart', ['pointChart']); |
||
| 75 | $list = Ranking::order($list, ['chartRank0' => SORT_DESC, 'chartRank1' => SORT_DESC, 'chartRank2' => SORT_DESC, 'chartRank3' => SORT_DESC]); |
||
| 76 | $list = Ranking::addRank($list, 'rankMedal', ['chartRank0', 'chartRank1', 'chartRank2', 'chartRank3', 'chartRank4', 'chartRank5']); |
||
| 77 | |||
| 78 | $normalizer = new ObjectNormalizer(); |
||
| 79 | $serializer = new Serializer([$normalizer]); |
||
| 80 | |||
| 81 | |||
| 82 | foreach ($list as $row) { |
||
| 83 | $playerSerie = $serializer->denormalize( |
||
| 84 | $row, 'VideoGamesRecords\CoreBundle\Entity\PlayerSerie' |
||
| 85 | ); |
||
| 86 | $playerSerie->setPlayer($this->em->getReference('VideoGamesRecords\CoreBundle\Entity\Player', $row['idPlayer'])); |
||
| 87 | $playerSerie->setSerie($serie); |
||
| 88 | |||
| 89 | $this->em->persist($playerSerie); |
||
| 90 | $this->em->flush(); |
||
| 91 | } |
||
| 94 |
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