Conditions | 9 |
Paths | 256 |
Total Lines | 61 |
Code Lines | 34 |
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 |
||
67 | private function getSessionList(User $user, AccessUrl $accessUrl, array $context = []): array |
||
68 | { |
||
69 | $qb = $this->sessionRepository->getUserFollowedSessionsInAccessUrl($user, $accessUrl); |
||
70 | |||
71 | if (!empty($context['filters']['startDate']['before'])) { |
||
72 | $qb |
||
73 | ->andWhere($qb->expr()->lte('s.displayStartDate', ':value_start')) |
||
74 | ->setParameter('value_start', $context['filters']['startDate']['before']) |
||
75 | ; |
||
76 | } |
||
77 | |||
78 | if (!empty($context['filters']['startDate']['after'])) { |
||
79 | $qb |
||
80 | ->andWhere($qb->expr()->gte('s.displayStartDate', ':value_start')) |
||
81 | ->setParameter('value_start', $context['filters']['startDate']['after']) |
||
82 | ; |
||
83 | } |
||
84 | |||
85 | if (!empty($context['filters']['startDate']['strictly_before'])) { |
||
86 | $qb |
||
87 | ->andWhere($qb->expr()->lt('s.displayStartDate', ':value_start')) |
||
88 | ->setParameter('value_start', $context['filters']['startDate']['strictly_before']) |
||
89 | ; |
||
90 | } |
||
91 | |||
92 | if (!empty($context['filters']['startDate']['strictly_after'])) { |
||
93 | $qb |
||
94 | ->andWhere($qb->expr()->gt('s.displayStartDate', ':value_start')) |
||
95 | ->setParameter('value_start', $context['filters']['startDate']['strictly_after']) |
||
96 | ; |
||
97 | } |
||
98 | |||
99 | if (!empty($context['filters']['endDate']['before'])) { |
||
100 | $qb |
||
101 | ->andWhere($qb->expr()->lte('s.displayEndDate', ':value_end')) |
||
102 | ->setParameter('value_end', $context['filters']['endDate']['before']) |
||
103 | ; |
||
104 | } |
||
105 | |||
106 | if (!empty($context['filters']['endDate']['after'])) { |
||
107 | $qb |
||
108 | ->andWhere($qb->expr()->gte('s.displayEndDate', ':value_end')) |
||
109 | ->setParameter('value_end', $context['filters']['endDate']['after']) |
||
110 | ; |
||
111 | } |
||
112 | |||
113 | if (!empty($context['filters']['endDate']['strictly_before'])) { |
||
114 | $qb |
||
115 | ->andWhere($qb->expr()->lt('s.displayEndDate', ':value_end')) |
||
116 | ->setParameter('value_end', $context['filters']['endDate']['strictly_before']) |
||
117 | ; |
||
118 | } |
||
119 | |||
120 | if (!empty($context['filters']['endDate']['strictly_after'])) { |
||
121 | $qb |
||
122 | ->andWhere($qb->expr()->gt('s.displayEndDate', ':value_end')) |
||
123 | ->setParameter('value_end', $context['filters']['endDate']['strictly_after']) |
||
124 | ; |
||
125 | } |
||
126 | |||
127 | return $qb->getQuery()->getResult(); |
||
128 | } |
||
130 |