Passed
Branch master (b6469e)
by Xavier
07:21 queued 05:06
created
src/Controller/UserController.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $events['moodle'] = null;
44 44
 
45 45
         if ($events['all'] != null) {
46
-            usort($events['all'], function ($a, $b) {
46
+            usort($events['all'], function($a, $b) {
47 47
                 return $a->eventTime < $b->eventTime;
48 48
             });
49 49
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         $events = Klass::eventsForUser($id, self::loggedUser());
131 131
 
132 132
         if ($events != null)
133
-            usort($events, function($a, $b) {return $a->eventTime < $b->eventTime;});
133
+            usort($events, function($a, $b) {return $a->eventTime < $b->eventTime; });
134 134
 
135 135
         return $this->render('User/class.twig', [
136 136
             'class' => $class,
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             }
164 164
 
165 165
             return $this->json($res);
166
-        }catch (Exception $e) {
166
+        } catch (Exception $e) {
167 167
             return new Response($e->getMessage(), 404);
168 168
         }
169 169
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,11 +55,13 @@  discard block
 block discarded – undo
55 55
             foreach ($events['all'] as $event) {
56 56
                 $date = date('Y-m-d', strtotime($event->eventTime));
57 57
                 if ($event->object->{'@type'} == 'SoftwareApplication') {
58
-                    if (array_key_exists($date, $cas_events))
59
-                        array_push($cas_events[$date], $event);
58
+                    if (array_key_exists($date, $cas_events)) {
59
+                                            array_push($cas_events[$date], $event);
60
+                    }
60 61
                 } else {
61
-                    if (array_key_exists($date, $moodle_events))
62
-                        array_push($moodle_events[$date], $event);
62
+                    if (array_key_exists($date, $moodle_events)) {
63
+                                            array_push($moodle_events[$date], $event);
64
+                    }
63 65
                 }
64 66
             }
65 67
 
@@ -129,8 +131,10 @@  discard block
 block discarded – undo
129 131
 
130 132
         $events = Klass::eventsForUser($id, self::loggedUser());
131 133
 
132
-        if ($events != null)
133
-            usort($events, function($a, $b) {return $a->eventTime < $b->eventTime;});
134
+        if ($events != null) {
135
+                    usort($events, function($a, $b) {return $a->eventTime < $b->eventTime;
136
+        }
137
+        });
134 138
 
135 139
         return $this->render('User/class.twig', [
136 140
             'class' => $class,
@@ -157,13 +161,14 @@  discard block
 block discarded – undo
157 161
                 $res[$i]['date'] = $result->date;
158 162
                 $res[$i]['score'] = $result->score;
159 163
                 foreach ($lineItems as $lineItem) {
160
-                    if ($lineItem->sourcedId == $result->lineitem->sourcedId)
161
-                        $res[$i]['title'] = $lineItem->title;
164
+                    if ($lineItem->sourcedId == $result->lineitem->sourcedId) {
165
+                                            $res[$i]['title'] = $lineItem->title;
166
+                    }
162 167
                 } $i++;
163 168
             }
164 169
 
165 170
             return $this->json($res);
166
-        }catch (Exception $e) {
171
+        } catch (Exception $e) {
167 172
             return new Response($e->getMessage(), 404);
168 173
         }
169 174
 
Please login to merge, or discard this patch.
src/Controller/AdminController.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
             $students = $this->ldap($filter, ['displayname', 'uid']);
37 37
             $res = [];
38 38
 
39
-            foreach($students as $student) {
39
+            foreach ($students as $student) {
40 40
                 if ($student['uid'][0] != null)
41
-                    $res += [ $student['uid'][0] => $student['displayname'][0] ];
41
+                    $res += [$student['uid'][0] => $student['displayname'][0]];
42 42
             }
43 43
 
44 44
             return $this->json($res);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function viewAs(Request $request, String $id)
58 58
     {
59
-        $_SESSION['username'] =  $_SESSION['phpCAS']['user'];
59
+        $_SESSION['username'] = $_SESSION['phpCAS']['user'];
60 60
         $_SESSION['phpCAS']['user'] = $id;
61 61
         return $this->redirectToRoute('home');
62 62
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,9 @@
 block discarded – undo
37 37
             $res = [];
38 38
 
39 39
             foreach($students as $student) {
40
-                if ($student['uid'][0] != null)
41
-                    $res += [ $student['uid'][0] => $student['displayname'][0] ];
40
+                if ($student['uid'][0] != null) {
41
+                                    $res += [ $student['uid'][0] => $student['displayname'][0] ];
42
+                }
42 43
             }
43 44
 
44 45
             return $this->json($res);
Please login to merge, or discard this patch.
src/Controller/HomeController.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,10 +25,11 @@
 block discarded – undo
25 25
      */
26 26
     public function index(Request $request)
27 27
     {
28
-        if (self::isUp())
29
-            return $this->render('home.twig');
30
-        else
31
-            return $this->render('Error/unavailable.twig');
28
+        if (self::isUp()) {
29
+                    return $this->render('home.twig');
30
+        } else {
31
+                    return $this->render('Error/unavailable.twig');
32
+        }
32 33
     }
33 34
 
34 35
     /**
Please login to merge, or discard this patch.
src/Controller/AbstractController.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
14 14
 use Symfony\Component\DependencyInjection\ContainerInterface;
15 15
 
16
- abstract class AbstractController extends Controller
16
+    abstract class AbstractController extends Controller
17 17
 {
18 18
 
19 19
     /**
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
         $container->set('http', self::$http);
34 34
     }
35 35
 
36
-     /**
37
-      * Creates and return a JSON Web Token through the OpenLRW API by using credentials filled in .env
38
-      *
39
-      * @return mixed|\Psr\Http\Message\ResponseInterface
40
-      * @throws \GuzzleHttp\Exception\GuzzleException
41
-      */
36
+        /**
37
+         * Creates and return a JSON Web Token through the OpenLRW API by using credentials filled in .env
38
+         *
39
+         * @return mixed|\Psr\Http\Message\ResponseInterface
40
+         * @throws \GuzzleHttp\Exception\GuzzleException
41
+         */
42 42
     public static function generateJwt()
43 43
     {
44 44
         $_SESSION['JWT'] = json_decode( self::$http->request('POST', 'api/auth/login', [
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
                 'password' => env('API_PASSWORD')
49 49
             ]
50 50
         ])->getBody()
51
-          ->getContents())->token;
51
+            ->getContents())->token;
52 52
 
53 53
         return $_SESSION['JWT'];
54 54
 
@@ -124,26 +124,26 @@  discard block
 block discarded – undo
124 124
         return ldap_get_entries($this->__get('ldap'), $this->searchLDAP($filter, $arg))[0];
125 125
     }
126 126
 
127
-     /**
128
-      * Function to check if OpenLRW is up
129
-      *
130
-      * @return boolean
131
-      * @throws \GuzzleHttp\Exception\GuzzleException
132
-      */
133
-     public static function isUp()
134
-     {
135
-         return self::$http->request('GET', '/info.json')->getStatusCode() == 200;
136
-     }
137
-
138
-     /**
139
-      * Get the logged username
140
-      *
141
-      * @return mixed
142
-      */
143
-     public static function loggedUser()
144
-     {
145
-         return $_SESSION['phpCAS']['user'];
146
-     }
127
+        /**
128
+         * Function to check if OpenLRW is up
129
+         *
130
+         * @return boolean
131
+         * @throws \GuzzleHttp\Exception\GuzzleException
132
+         */
133
+        public static function isUp()
134
+        {
135
+            return self::$http->request('GET', '/info.json')->getStatusCode() == 200;
136
+        }
137
+
138
+        /**
139
+         * Get the logged username
140
+         *
141
+         * @return mixed
142
+         */
143
+        public static function loggedUser()
144
+        {
145
+            return $_SESSION['phpCAS']['user'];
146
+        }
147 147
 
148 148
 
149 149
 }
150 150
\ No newline at end of file
Please login to merge, or discard this patch.
src/Model/API/ApiModel.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -68,10 +68,10 @@
 block discarded – undo
68 68
      */
69 69
     public function post(String $route, array $args) // ToDo : add JWT
70 70
     {
71
-       return json_decode( self::$http->request('POST', $route, [
72
-           'headers' => [ 'X-Requested-With' => 'XMLHttpRequest' ],
73
-           'json' => $args
74
-       ])->getBody()->getContents());
71
+        return json_decode( self::$http->request('POST', $route, [
72
+            'headers' => [ 'X-Requested-With' => 'XMLHttpRequest' ],
73
+            'json' => $args
74
+        ])->getBody()->getContents());
75 75
     }
76 76
 
77 77
 
Please login to merge, or discard this patch.