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