Conditions | 10 |
Paths | 34 |
Total Lines | 42 |
Code Lines | 27 |
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 |
||
56 | public function getEventPages(Event $event, $reviewSlug = null) |
||
57 | { |
||
58 | if ($event->isAdminOnly() && !$this->authorizationChecker->isGranted('ROLE_ADMIN')) { |
||
59 | throw new NotFoundHttpException(sprintf('Unable to find event by slug: %s', $event->getSlug())); |
||
60 | } |
||
61 | $review = null; |
||
62 | if ($reviewSlug) { |
||
63 | $review = $this->reviewRepository->findOneBy(['slug' => $reviewSlug]); |
||
64 | |||
65 | if (!$review) { |
||
66 | throw new NotFoundHttpException('Unable to find Review entity.'); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | /** @var ArrayCollection $pages */ |
||
71 | $pages = $this->getEventMenuPages($event); |
||
72 | |||
73 | /** @var EventPage $page */ |
||
74 | $programPage = null; |
||
75 | $venuePage = null; |
||
76 | foreach ($pages as $key => $page) { |
||
77 | if ('program' === $page->getSlug()) { |
||
78 | $programPage = $page; |
||
79 | unset($pages[$key]); |
||
80 | } elseif ('venue' === $page->getSlug()) { |
||
81 | $venuePage = $page; |
||
82 | unset($pages[$key]); |
||
83 | } |
||
84 | } |
||
85 | |||
86 | $eventCurrentAmount = $this->ticketCostRepository->getEventCurrentCost($event); |
||
87 | |||
88 | $futureEvent = !$event->isActiveAndFuture() && $event->getGroup() instanceof EventGroup ? $this->eventRepository->findFutureEventFromSameGroup($event->getGroup()) : null; |
||
89 | |||
90 | return [ |
||
91 | 'event' => $event, |
||
92 | 'programPage' => $programPage, |
||
93 | 'venuePage' => $venuePage, |
||
94 | 'pages' => $pages, |
||
95 | 'review' => $review, |
||
96 | 'eventCurrentAmount' => $eventCurrentAmount, |
||
97 | 'futureEvent' => $futureEvent, |
||
98 | ]; |
||
141 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.