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