Passed
Push — master ( 6b82c7...2509cd )
by Marcel
16:43
created
src/Controller/ListController.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -75,29 +75,29 @@  discard block
 block discarded – undo
75 75
         $studentFilterView = $studentFilter->handle($request->query->get('student', null), $sectionFilterView->getCurrentSection(), $user);
76 76
         $teacherFilterView = $teacherFilter->handle($request->query->get('teacher', null), $sectionFilterView->getCurrentSection(), $user, $gradeFilterView->getCurrentGrade() === null && $studentFilterView->getCurrentStudent() === null);
77 77
 
78
-        $tuitions = [ ];
79
-        $memberships = [ ];
80
-        $teacherMailAddresses = [ ];
78
+        $tuitions = [];
79
+        $memberships = [];
80
+        $teacherMailAddresses = [];
81 81
 
82
-        if($studentFilterView->getCurrentStudent() !== null && $sectionFilterView->getCurrentSection() !== null) {
82
+        if ($studentFilterView->getCurrentStudent() !== null && $sectionFilterView->getCurrentSection() !== null) {
83 83
             $tuitions = $tuitionRepository->findAllByStudents([$studentFilterView->getCurrentStudent()], $sectionFilterView->getCurrentSection());
84 84
 
85
-            foreach($tuitions as $tuition) {
85
+            foreach ($tuitions as $tuition) {
86 86
                 /** @var StudyGroupMembership|null $membership */
87 87
                 $membership = $tuition->getStudyGroup()->getMemberships()->filter(fn(StudyGroupMembership $membership) => $membership->getStudent()->getId() === $studentFilterView->getCurrentStudent()->getId())->first();
88 88
 
89 89
                 $memberships[$tuition->getExternalId()] = $membership->getType();
90 90
             }
91
-        } else if($gradeFilterView->getCurrentGrade() !== null) {
91
+        } else if ($gradeFilterView->getCurrentGrade() !== null) {
92 92
             $tuitions = $tuitionRepository->findAllByGrades([$gradeFilterView->getCurrentGrade()], $sectionFilterView->getCurrentSection());
93
-        } else if($teacherFilterView->getCurrentTeacher() !== null && $sectionFilterView->getCurrentSection() !== null) {
93
+        } else if ($teacherFilterView->getCurrentTeacher() !== null && $sectionFilterView->getCurrentSection() !== null) {
94 94
             $tuitions = $tuitionRepository->findAllByTeacher($teacherFilterView->getCurrentTeacher(), $sectionFilterView->getCurrentSection());
95 95
         }
96 96
 
97
-        if($studentFilterView->getCurrentStudent() !== null || $gradeFilterView->getCurrentGrade() !== null) {
98
-            foreach($tuitions as $tuition) {
99
-                foreach($tuition->getTeachers() as $teacher) {
100
-                    if($teacher->getEmail() !== null) {
97
+        if ($studentFilterView->getCurrentStudent() !== null || $gradeFilterView->getCurrentGrade() !== null) {
98
+            foreach ($tuitions as $tuition) {
99
+                foreach ($tuition->getTeachers() as $teacher) {
100
+                    if ($teacher->getEmail() !== null) {
101 101
                         $teacherMailAddresses[] = $teacher->getEmail();
102 102
                     }
103 103
                 }
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
 
136 136
         $exams = array_filter($exams, fn(Exam $exam) => $this->isGranted(ExamVoter::Show, $exam));
137 137
 
138
-        $types = [ ];
138
+        $types = [];
139 139
 
140
-        foreach($memberships as $membership) {
141
-            if(!array_key_exists($membership->getType(), $types)) {
140
+        foreach ($memberships as $membership) {
141
+            if (!array_key_exists($membership->getType(), $types)) {
142 142
                 $types[$membership->getType()] = 0;
143 143
             }
144 144
 
@@ -174,24 +174,24 @@  discard block
 block discarded – undo
174 174
         $studyGroupFilterView = $studyGroupFilter->handle($request->query->get('study_group', null), $sectionFilterView->getCurrentSection(), $user);
175 175
         $studentFilterView = $studentFilter->handle($request->query->get('student', null), $sectionFilterView->getCurrentSection(), $user);
176 176
 
177
-        $students = [ ];
178
-        $studyGroups = [ ];
179
-        $memberships = [ ];
177
+        $students = [];
178
+        $studyGroups = [];
179
+        $memberships = [];
180 180
 
181
-        if($studyGroupFilterView->getCurrentStudyGroup() !== null) {
181
+        if ($studyGroupFilterView->getCurrentStudyGroup() !== null) {
182 182
             /** @var StudyGroupMembership $membership */
183
-            foreach($studyGroupFilterView->getCurrentStudyGroup()->getMemberships() as $membership) {
183
+            foreach ($studyGroupFilterView->getCurrentStudyGroup()->getMemberships() as $membership) {
184 184
                 $students[] = $membership->getStudent();
185 185
                 $memberships[$membership->getStudent()->getId()] = $membership->getType();
186 186
             }
187 187
 
188 188
             $this->sorter->sort($students, StudentStrategy::class);
189
-        } else if($studentFilterView->getCurrentStudent() !== null) {
190
-            $studyGroups = [ ];
191
-            $memberships = [ ];
189
+        } else if ($studentFilterView->getCurrentStudent() !== null) {
190
+            $studyGroups = [];
191
+            $memberships = [];
192 192
 
193 193
             /** @var StudyGroupMembership $membership */
194
-            foreach($studentFilterView->getCurrentStudent()->getStudyGroupMemberships() as $membership) {
194
+            foreach ($studentFilterView->getCurrentStudent()->getStudyGroupMemberships() as $membership) {
195 195
                 $studyGroups[] = $membership->getStudyGroup();
196 196
                 $memberships[$membership->getStudyGroup()->getId()] = $membership->getType();
197 197
             }
@@ -202,26 +202,26 @@  discard block
 block discarded – undo
202 202
         $studyGroups = array_filter($studyGroups, fn(StudyGroup $studyGroup) => $studyGroup->getSection() === $sectionFilterView->getCurrentSection());
203 203
 
204 204
         $grade = null;
205
-        $gradeTeachers = [ ];
206
-        $substitutionalGradeTeachers = [ ];
205
+        $gradeTeachers = [];
206
+        $substitutionalGradeTeachers = [];
207 207
 
208
-        if($studyGroupFilterView->getCurrentStudyGroup() !== null && $studyGroupFilterView->getCurrentStudyGroup()->getType() === StudyGroupType::Grade) {
208
+        if ($studyGroupFilterView->getCurrentStudyGroup() !== null && $studyGroupFilterView->getCurrentStudyGroup()->getType() === StudyGroupType::Grade) {
209 209
             /** @var Grade $grade */
210 210
             $grade = $studyGroupFilterView->getCurrentStudyGroup()->getGrades()->first();
211
-        } else if($studentFilterView->getCurrentStudent() !== null && $sectionFilterView->getCurrentSection() !== null) {
211
+        } else if ($studentFilterView->getCurrentStudent() !== null && $sectionFilterView->getCurrentSection() !== null) {
212 212
             $grade = $studentFilterView->getCurrentStudent()->getGrade($sectionFilterView->getCurrentSection());
213 213
         }
214 214
 
215
-        if($grade !== null) {
215
+        if ($grade !== null) {
216 216
             $gradeTeachers = array_map(fn(GradeTeacher $gradeTeacher) => $gradeTeacher->getTeacher(), array_filter($grade->getTeachers()->toArray(), fn(GradeTeacher $gradeTeacher) => $gradeTeacher->getType() === GradeTeacherType::Primary));
217 217
 
218 218
             $substitutionalGradeTeachers = array_map(fn(GradeTeacher $gradeTeacher) => $gradeTeacher->getTeacher(), array_filter($grade->getTeachers()->toArray(), fn(GradeTeacher $gradeTeacher) => $gradeTeacher->getType() === GradeTeacherType::Substitute));
219 219
         }
220 220
 
221
-        $tuitions = [ ];
221
+        $tuitions = [];
222 222
 
223
-        if($studyGroupFilterView->getCurrentStudyGroup() !== null) {
224
-            if($studyGroupFilterView->getCurrentStudyGroup()->getType() === StudyGroupType::Grade) {
223
+        if ($studyGroupFilterView->getCurrentStudyGroup() !== null) {
224
+            if ($studyGroupFilterView->getCurrentStudyGroup()->getType() === StudyGroupType::Grade) {
225 225
                 $tuitions = $tuitionRepository->findAllByGrades($studyGroupFilterView->getCurrentStudyGroup()->getGrades()->toArray(), $sectionFilterView->getCurrentSection());
226 226
             } else {
227 227
                 $tuitions = $studyGroupFilterView->getCurrentStudyGroup()->getTuitions()->toArray();
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 
266 266
         $teachers = $teacherRepository->findAllBySubjectAndTag($subjectFilterView->getCurrentSubject(), $tagFilterView->getCurrentTag());
267 267
 
268
-        if($tagFilterView->getCurrentTag() !== null && $tagFilterView->getCurrentTag()->getId() === null) {
268
+        if ($tagFilterView->getCurrentTag() !== null && $tagFilterView->getCurrentTag()->getId() === null) {
269 269
             $teachers = $this->filterImplicitTeacherTag($teachers, $tagFilterView->getCurrentTag());
270 270
         }
271 271
 
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
     private function filterImplicitTeacherTag(array $teachers, TeacherTag $tag): array {
290 290
         return array_filter($teachers, function(Teacher $teacher) use ($tag) {
291 291
             /** @var GradeTeacher $gradeTeacher */
292
-            foreach($teacher->getGrades() as $gradeTeacher) {
293
-                if($gradeTeacher->getType() === GradeTeacherType::Primary && $tag->getUuid()->toString() === TeacherTag::GradeTeacherTagUuid) {
292
+            foreach ($teacher->getGrades() as $gradeTeacher) {
293
+                if ($gradeTeacher->getType() === GradeTeacherType::Primary && $tag->getUuid()->toString() === TeacherTag::GradeTeacherTagUuid) {
294 294
                     return true;
295 295
                 }
296 296
 
297
-                if($gradeTeacher->getType() === GradeTeacherType::Substitute && $tag->getUuid()->toString() === TeacherTag::SubstituteGradeTeacherTagUuid) {
297
+                if ($gradeTeacher->getType() === GradeTeacherType::Substitute && $tag->getUuid()->toString() === TeacherTag::SubstituteGradeTeacherTagUuid) {
298 298
                     return true;
299 299
                 }
300 300
             }
@@ -315,19 +315,19 @@  discard block
 block discarded – undo
315 315
 
316 316
         // Filter categories
317 317
         $categories = $privacyCategoryRepository->findAll();
318
-        $filteredCategories = [ ];
318
+        $filteredCategories = [];
319 319
 
320
-        foreach($categories as $category) {
321
-            if($request->query->get($category->getUuid()->toString()) === '✓') {
320
+        foreach ($categories as $category) {
321
+            if ($request->query->get($category->getUuid()->toString()) === '✓') {
322 322
                 $filteredCategories[] = $category->getUuid()->toString();
323 323
             }
324 324
         }
325 325
 
326
-        $students = [ ];
326
+        $students = [];
327 327
 
328
-        if($q !== null) {
328
+        if ($q !== null) {
329 329
             $students = $studentRepository->findAllByQuery($q);
330
-        } else if($studygroupView->getCurrentStudyGroup() !== null) {
330
+        } else if ($studygroupView->getCurrentStudyGroup() !== null) {
331 331
             $students = $studentRepository->findAllByStudyGroups([$studygroupView->getCurrentStudyGroup()]);
332 332
         }
333 333
 
Please login to merge, or discard this patch.
src/Controller/AuthenticationController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@
 block discarded – undo
14 14
     public function error(AuthenticationUtils $authenticationUtils, TranslatorInterface $translator): Response {
15 15
         $exception = $authenticationUtils->getLastAuthenticationError();
16 16
 
17
-        if($exception === null) {
17
+        if ($exception === null) {
18 18
             return $this->redirectToRoute('lightsaml_sp.login');
19 19
         }
20 20
 
21
-        if($exception->getPrevious() !== null) {
21
+        if ($exception->getPrevious() !== null) {
22 22
             $exception = $exception->getPrevious();
23 23
         }
24 24
 
25 25
         $exceptionType = $exception::class;
26 26
 
27
-        if(method_exists($exception, 'getMessageKey')) {
27
+        if (method_exists($exception, 'getMessageKey')) {
28 28
             $messageKey = $exception->getMessageKey();
29 29
             $message = $translator->trans($messageKey, [], 'security');
30 30
         } else {
Please login to merge, or discard this patch.