| Conditions | 4 |
| Paths | 5 |
| Total Lines | 59 |
| Code Lines | 25 |
| 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 |
||
| 12 | public function handle($mixed): void |
||
| 13 | { |
||
| 14 | $group = $this->em->getRepository('VideoGamesRecords\CoreBundle\Entity\Group')->find($mixed); |
||
| 15 | if (null === $group) { |
||
| 16 | return; |
||
| 17 | } |
||
| 18 | |||
| 19 | //----- delete |
||
| 20 | $query = $this->em->createQuery( |
||
| 21 | 'DELETE VideoGamesRecords\CoreBundle\Entity\TeamGroup tg WHERE tg.group = :group' |
||
| 22 | ); |
||
| 23 | $query->setParameter('group', $group); |
||
| 24 | $query->execute(); |
||
| 25 | |||
| 26 | //----- select ans save result in array |
||
| 27 | $query = $this->em->createQuery(" |
||
| 28 | SELECT |
||
| 29 | t.id, |
||
| 30 | '' as rankPointChart, |
||
| 31 | '' as rankMedal, |
||
| 32 | SUM(tc.chartRank0) as chartRank0, |
||
| 33 | SUM(tc.chartRank1) as chartRank1, |
||
| 34 | SUM(tc.chartRank2) as chartRank2, |
||
| 35 | SUM(tc.chartRank3) as chartRank3, |
||
| 36 | SUM(tc.pointChart) as pointChart |
||
| 37 | FROM VideoGamesRecords\CoreBundle\Entity\TeamChart tc |
||
| 38 | JOIN tc.chart c |
||
| 39 | JOIN tc.team t |
||
| 40 | WHERE c.group = :group |
||
| 41 | GROUP BY t.id |
||
| 42 | ORDER BY pointChart DESC"); |
||
| 43 | |||
| 44 | |||
| 45 | $query->setParameter('group', $group); |
||
| 46 | $result = $query->getResult(); |
||
| 47 | |||
| 48 | $list = []; |
||
| 49 | foreach ($result as $row) { |
||
| 50 | $list[] = $row; |
||
| 51 | } |
||
| 52 | |||
| 53 | //----- add some data |
||
| 54 | $list = Ranking::addRank($list, 'rankPointChart', ['pointChart'], true); |
||
| 55 | $list = Ranking::order($list, ['chartRank0' => SORT_DESC, 'chartRank1' => SORT_DESC, 'chartRank2' => SORT_DESC, 'chartRank3' => SORT_DESC]); |
||
| 56 | $list = Ranking::addRank($list, 'rankMedal', ['chartRank0', 'chartRank1', 'chartRank2', 'chartRank3']); |
||
| 57 | |||
| 58 | $normalizer = new ObjectNormalizer(); |
||
| 59 | $serializer = new Serializer([$normalizer]); |
||
| 60 | |||
| 61 | foreach ($list as $row) { |
||
| 62 | $teamGroup = $serializer->denormalize( |
||
| 63 | $row, 'VideoGamesRecords\CoreBundle\Entity\TeamGroup' |
||
| 64 | ); |
||
| 65 | $teamGroup->setTeam($this->em->getReference('VideoGamesRecords\CoreBundle\Entity\Team', $row['id'])); |
||
| 66 | $teamGroup->setGroup($group); |
||
| 67 | |||
| 68 | $this->em->persist($teamGroup); |
||
| 69 | } |
||
| 70 | $this->em->flush(); |
||
| 71 | } |
||
| 73 |
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