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