Conditions | 5 |
Paths | 7 |
Total Lines | 68 |
Code Lines | 30 |
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 |
||
15 | public function handle($mixed): void |
||
16 | { |
||
17 | /** @var Game $game */ |
||
18 | $game = $this->em->getRepository('VideoGamesRecords\CoreBundle\Entity\Game')->find($mixed); |
||
19 | if (null === $game) { |
||
20 | return; |
||
21 | } |
||
22 | |||
23 | //----- delete |
||
24 | $query = $this->em->createQuery( |
||
25 | 'DELETE VideoGamesRecords\CoreBundle\Entity\TeamGame tg WHERE tg.game = :game' |
||
26 | ); |
||
27 | $query->setParameter('game', $game); |
||
28 | $query->execute(); |
||
29 | |||
30 | //----- select ans save result in array |
||
31 | $query = $this->em->createQuery(" |
||
32 | SELECT |
||
33 | t.id, |
||
34 | '' as rankPointChart, |
||
35 | '' as rankMedal, |
||
36 | SUM(tg.chartRank0) as chartRank0, |
||
37 | SUM(tg.chartRank1) as chartRank1, |
||
38 | SUM(tg.chartRank2) as chartRank2, |
||
39 | SUM(tg.chartRank3) as chartRank3, |
||
40 | SUM(tg.pointChart) as pointChart |
||
41 | FROM VideoGamesRecords\CoreBundle\Entity\TeamGroup tg |
||
42 | JOIN tg.group g |
||
43 | JOIN tg.team t |
||
44 | WHERE g.game = :game |
||
45 | GROUP BY t.id |
||
46 | ORDER BY pointChart DESC"); |
||
47 | |||
48 | |||
49 | $query->setParameter('game', $game); |
||
50 | $result = $query->getResult(); |
||
51 | |||
52 | $list = []; |
||
53 | foreach ($result as $row) { |
||
54 | $list[] = $row; |
||
55 | } |
||
56 | |||
57 | $game->setNbTeam(count($list)); |
||
58 | |||
59 | //----- add some data |
||
60 | $list = Ranking::addRank($list, 'rankPointChart', ['pointChart'], true); |
||
61 | $list = Ranking::order($list, ['chartRank0' => SORT_DESC, 'chartRank1' => SORT_DESC, 'chartRank2' => SORT_DESC, 'chartRank3' => SORT_DESC]); |
||
62 | $list = Ranking::addRank($list, 'rankMedal', ['chartRank0', 'chartRank1', 'chartRank2', 'chartRank3']); |
||
63 | $list = Ranking::calculateGamePoints($list, array('rankPointChart', 'nbEqual'), 'pointGame', 'pointChart'); |
||
64 | |||
65 | $normalizer = new ObjectNormalizer(); |
||
66 | $serializer = new Serializer([$normalizer]); |
||
67 | |||
68 | foreach ($list as $row) { |
||
69 | if (isset($row['id'])) { |
||
70 | $teamGame = $serializer->denormalize( |
||
71 | $row, 'VideoGamesRecords\CoreBundle\Entity\TeamGame' |
||
72 | ); |
||
73 | $teamGame->setTeam($this->em->getReference('VideoGamesRecords\CoreBundle\Entity\Team', $row['id'])); |
||
74 | $teamGame->setGame($game); |
||
75 | |||
76 | $this->em->persist($teamGame); |
||
77 | } |
||
78 | } |
||
79 | $this->em->flush(); |
||
80 | |||
81 | $event = new GameEvent($game); |
||
82 | $this->eventDispatcher->dispatch($event, VideoGamesRecordsCoreEvents::TEAM_GAME_MAJ_COMPLETED); |
||
83 | } |
||
85 |
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