Test Setup Failed
Branch master (6ec315)
by Phil™
04:55
created
src/LearningLocker/Stores/StoreHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
      *
28 28
      * @return  $response
29 29
      */
30
-    public function get($selected = []) {
30
+    public function get($selected = [ ]) {
31 31
         try {
32 32
             $url = $this->url . $this->api . $this->v2 . $this->store . '/' . $this->id ?? $this->id;
33 33
             $response = $this->request($url);
Please login to merge, or discard this patch.
src/LearningLocker/Connection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
   }
51 51
 
52 52
   protected function auth() {
53
-    return [$this->key, $this->secret];
53
+    return [ $this->key, $this->secret ];
54 54
   }
55 55
 
56 56
   protected function headers() {
Please login to merge, or discard this patch.
src/LearningLocker/Client/Client.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
       ],
34 34
     ]);
35 35
 
36
-    if($request->getStatusCode() === 404) {
36
+    if ($request->getStatusCode() === 404) {
37 37
       throw new Exception('There was a issue connecting to Learning Locker.');
38 38
     }
39 39
 
Please login to merge, or discard this patch.
src/LearningLocker/Client/ClientHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      *
29 29
      * @return  $response
30 30
      */
31
-    public function get($selected = []) {
31
+    public function get($selected = [ ]) {
32 32
         try {
33 33
             $url = $this->url . $this->api . $this->v2 . $this->client . '/' . $this->id ??  $this->id;
34 34
             $response = $this->request($url);
Please login to merge, or discard this patch.
src/LearningLocker/Statements/StatementGenerator.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
 class StatementGenerator {
9 9
 
10
-    const LL_COURSE_EXTENSION  = 'http://learninglocker.net/extensions/course';
11
-    const COMMENT_EXTENSION  = 'http://curatr3.com/define/extension/commentText';
12
-    const BADGE_EXTENSION  = 'http://specification.openbadges.org/xapi/extensions/badgeassertion';
13
-    const MCQ_SINGLE_EXTENSION  = 'http://curatr3.com/define/extension/single-mcq-option';
14
-    const MCQ_MULTIPLE_EXTENSION  = 'http://curatr3.com/define/extension/multiple-mcq-options';
15
-    const CONTRIBUTION_OBJECT  = 'http://curatr3.com/define/extension/contribution-object';
10
+    const LL_COURSE_EXTENSION = 'http://learninglocker.net/extensions/course';
11
+    const COMMENT_EXTENSION = 'http://curatr3.com/define/extension/commentText';
12
+    const BADGE_EXTENSION = 'http://specification.openbadges.org/xapi/extensions/badgeassertion';
13
+    const MCQ_SINGLE_EXTENSION = 'http://curatr3.com/define/extension/single-mcq-option';
14
+    const MCQ_MULTIPLE_EXTENSION = 'http://curatr3.com/define/extension/multiple-mcq-options';
15
+    const CONTRIBUTION_OBJECT = 'http://curatr3.com/define/extension/contribution-object';
16 16
     const BADGE_TYPE = 'http://activitystrea.ms/schema/1.0/badge';
17 17
     const CATEGORY_TYPE = 'http://activitystrea.ms/schema/1.0/collection';
18 18
     const COLLECTION_TYPE = 'http://curatr3.com/define/type/collection';
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
     public $url, $statement, $endpoints, $log;
34 34
 
35
-    public function __construct( $endpoints=array() ) {
35
+    public function __construct($endpoints = array()) {
36 36
 
37 37
       $this->log = \App::make('xapi.log');
38 38
       $this->endpoints = $endpoints;
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
   * @param type $default Default to return if key is not set
46 46
   * @return mixed
47 47
   */
48
-    private static function checkKey( $array, $key, $default='' ){
49
-        return (isset($array[$key]) && !empty($array[$key])) ? $array[$key] : $default;
48
+    private static function checkKey($array, $key, $default = '') {
49
+        return (isset($array[ $key ]) && !empty($array[ $key ])) ? $array[ $key ] : $default;
50 50
     }
51 51
 
52 52
   /**
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
   public function buildStatement($data) {
57 57
 
58 58
     $actor      = $this->checkKey($data, 'actor');
59
-    $verb       = $this->checkKey($data, 'verb',        self::getVerb('experienced') );
59
+    $verb       = $this->checkKey($data, 'verb', self::getVerb('experienced'));
60 60
     $object     = $this->checkKey($data, 'object');
61
-    $authority  = $this->checkKey($data, 'authority', []);
62
-    $context    = $this->checkKey($data, 'context', [] );
63
-    $result     = $this->checkKey($data, 'result', [] );
64
-    $timestamp  = $this->checkKey($data, 'timestamp',   Carbon::now()->format("c") );
61
+    $authority  = $this->checkKey($data, 'authority', [ ]);
62
+    $context    = $this->checkKey($data, 'context', [ ]);
63
+    $result     = $this->checkKey($data, 'result', [ ]);
64
+    $timestamp  = $this->checkKey($data, 'timestamp', Carbon::now()->format("c"));
65 65
 
66 66
     $this->statement = array(
67 67
       'actor'     => $actor,
@@ -70,48 +70,48 @@  discard block
 block discarded – undo
70 70
       'timestamp' => $timestamp
71 71
     );
72 72
 
73
-    if( isset($result) && !empty($result) ){
74
-        $this->statement['result'] = $result;
73
+    if (isset($result) && !empty($result)) {
74
+        $this->statement[ 'result' ] = $result;
75 75
     }
76 76
 
77
-    if( isset($authority) && !empty($authority) ){
78
-        $this->statement['authority'] = $authority;
77
+    if (isset($authority) && !empty($authority)) {
78
+        $this->statement[ 'authority' ] = $authority;
79 79
     }
80 80
 
81
-    if( isset($context) && !empty($context) ){
82
-        $this->statement['context'] = $context;
81
+    if (isset($context) && !empty($context)) {
82
+        $this->statement[ 'context' ] = $context;
83 83
     } else {
84
-      $this->statement['context'] = $this->createContext();
84
+      $this->statement[ 'context' ] = $this->createContext();
85 85
     }
86 86
 
87 87
     //Add the org to the contextActivites
88 88
     $org = \Organisation::userCurrent();
89
-    if( $org ){
90
-      if( !isset($this->statement['context']['contextActivities']) ){
91
-        $this->statement['context']['contextActivities'] = [];
89
+    if ($org) {
90
+      if (!isset($this->statement[ 'context' ][ 'contextActivities' ])) {
91
+        $this->statement[ 'context' ][ 'contextActivities' ] = [ ];
92 92
       }
93 93
 
94
-      if( !isset($this->statement['context']['contextActivities']['grouping']) ){
95
-        $this->statement['context']['contextActivities']['grouping'] = [];
96
-      } elseif( !isset($this->statement['context']['contextActivities']['grouping'][0])){
97
-        $val = $this->statement['context']['contextActivities']['grouping'];
98
-        $this->statement['context']['contextActivities']['grouping'] = [ $val ];
94
+      if (!isset($this->statement[ 'context' ][ 'contextActivities' ][ 'grouping' ])) {
95
+        $this->statement[ 'context' ][ 'contextActivities' ][ 'grouping' ] = [ ];
96
+      } elseif (!isset($this->statement[ 'context' ][ 'contextActivities' ][ 'grouping' ][ 0 ])) {
97
+        $val = $this->statement[ 'context' ][ 'contextActivities' ][ 'grouping' ];
98
+        $this->statement[ 'context' ][ 'contextActivities' ][ 'grouping' ] = [ $val ];
99 99
       }
100 100
 
101
-      $this->statement['context']['contextActivities']['grouping'][] = $org->tcExtension();
101
+      $this->statement[ 'context' ][ 'contextActivities' ][ 'grouping' ][ ] = $org->tcExtension();
102 102
     }
103 103
 
104 104
     // remove context.platform if NOT an activity (xAPI 4.1.6)
105 105
     if (
106
-        isset($this->statement['context'])
107
-        && isset($this->statement['object'], $this->statement['object']['objectType'])
108
-        && strtolower($this->statement['object']['objectType']) !== strtolower('activity')
106
+        isset($this->statement[ 'context' ])
107
+        && isset($this->statement[ 'object' ], $this->statement[ 'object' ][ 'objectType' ])
108
+        && strtolower($this->statement[ 'object' ][ 'objectType' ]) !== strtolower('activity')
109 109
         ) {
110
-      if (isset($this->statement['context']['platform'])) {
111
-        unset($this->statement['context']['platform']);
110
+      if (isset($this->statement[ 'context' ][ 'platform' ])) {
111
+        unset($this->statement[ 'context' ][ 'platform' ]);
112 112
       }
113
-      if (isset($this->statement['context']['revision'])) {
114
-        unset($this->statement['context']['revision']);
113
+      if (isset($this->statement[ 'context' ][ 'revision' ])) {
114
+        unset($this->statement[ 'context' ][ 'revision' ]);
115 115
       }
116 116
     }
117 117
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
   * @param string $email
127 127
   * @return array
128 128
   */
129
-    public static function createMboxActor( $name, $email ){
129
+    public static function createMboxActor($name, $email) {
130 130
         return array(
131 131
             'name'          =>  $name,
132 132
             'mbox'          =>  'mailto:' . $email,
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
      * @param string $ref
143 143
      * @return array
144 144
      */
145
-    public static function createAccountActor( $name, $homepage, $ref ){
145
+    public static function createAccountActor($name, $homepage, $ref) {
146 146
       return [
147 147
           'name'          => $name,
148
-          'account'       => ['homePage' => $homepage, 'name' => $ref],
148
+          'account'       => [ 'homePage' => $homepage, 'name' => $ref ],
149 149
           'objectType'    => 'Agent'
150 150
       ];
151 151
     }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      * @param string $email
158 158
      * @return array
159 159
      */
160
-    public static function createAuthority( $name, $email ){
160
+    public static function createAuthority($name, $email) {
161 161
         return array(
162 162
             'name'          =>  $name,
163 163
             'mbox'          =>  'mailto:' . $email,
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * Generates the result part of the statement
171 171
      * @return array
172 172
      */
173
-    public static function createResult( $result=array() ){
173
+    public static function createResult($result = array()) {
174 174
 
175 175
         return $result;
176 176
 
@@ -182,18 +182,18 @@  discard block
 block discarded – undo
182 182
      * @todo hardcoded for now
183 183
      * @return array
184 184
      */
185
-    public static function createContext( $extensions = array(), $additional=null ){
185
+    public static function createContext($extensions = array(), $additional = null) {
186 186
 
187 187
         $context = array(
188 188
             'platform'  =>  'Curatr'
189 189
         );
190 190
 
191
-        if( !empty($extensions) ){
192
-          $context['extensions'] = $extensions;
191
+        if (!empty($extensions)) {
192
+          $context[ 'extensions' ] = $extensions;
193 193
         }
194 194
 
195
-        if( !is_null($additional) ){
196
-            $context = array_merge($context, $additional );
195
+        if (!is_null($additional)) {
196
+            $context = array_merge($context, $additional);
197 197
         }
198 198
 
199 199
         return $context;
@@ -206,119 +206,119 @@  discard block
 block discarded – undo
206 206
   * @param string $key The verb to use
207 207
   * @return array
208 208
   */
209
-    public static function getVerb( $key ){
209
+    public static function getVerb($key) {
210 210
 
211 211
         $verbs = array();
212 212
 
213 213
         $available_verbs = self::returnAvailableVerbs();
214 214
 
215 215
         // add all official verbs
216
-        foreach( $available_verbs as $v ){
217
-            $verbs[$v] = array(
216
+        foreach ($available_verbs as $v) {
217
+            $verbs[ $v ] = array(
218 218
                 "id"        =>  "http://adlnet.gov/expapi/verbs/{$v}",
219
-                "display"   =>  array( "en-GB" =>  $v ),
219
+                "display"   =>  array("en-GB" =>  $v),
220 220
             );
221 221
         }
222 222
 
223 223
         // Standard Verbs
224
-        $verbs['commented'] = array(
224
+        $verbs[ 'commented' ] = array(
225 225
             "id"        =>  "http://adlnet.gov/expapi/verbs/commented",
226
-            "display"   =>  array(  "en-GB" =>  "commented on" )
226
+            "display"   =>  array("en-GB" =>  "commented on")
227 227
         );
228
-        $verbs['coached'] = array(
228
+        $verbs[ 'coached' ] = array(
229 229
             "id"        =>  "http://learninglocker.net/verbs/coached-in",
230
-            "display"   =>  array(  "en-GB" =>  "coached in" )
230
+            "display"   =>  array("en-GB" =>  "coached in")
231 231
         );
232
-        $verbs['mentored'] = array(
232
+        $verbs[ 'mentored' ] = array(
233 233
             "id"        =>  "http://learninglocker.net/verbs/mentored-in",
234
-            "display"   =>  array(  "en-GB" =>  "mentored in" )
234
+            "display"   =>  array("en-GB" =>  "mentored in")
235 235
         );
236
-        $verbs['observed'] = array(
236
+        $verbs[ 'observed' ] = array(
237 237
             "id"        =>  "http://learninglocker.net/verbs/observed-in",
238
-            "display"   =>  array(  "en-GB" =>  "observed in" )
238
+            "display"   =>  array("en-GB" =>  "observed in")
239 239
         );
240
-        $verbs['trained'] = array(
240
+        $verbs[ 'trained' ] = array(
241 241
             "id"        =>  "http://learninglocker.net/verbs/trained-in",
242
-            "display"   =>  array(  "en-GB" =>  "trained in" )
242
+            "display"   =>  array("en-GB" =>  "trained in")
243 243
         );
244
-        $verbs['endorsed'] = array(
244
+        $verbs[ 'endorsed' ] = array(
245 245
             "id"        =>  "http://learninglocker.net/verbs/endorsed-in",
246
-            "display"   =>  array(  "en-GB" =>  "endorsed in" )
246
+            "display"   =>  array("en-GB" =>  "endorsed in")
247 247
         );
248
-        $verbs['posted'] = array(
248
+        $verbs[ 'posted' ] = array(
249 249
             "id"        =>  "http://curatr3.com/define/verb/posted",
250
-            "display"   =>  array( "en-GB" =>  "posted" )
250
+            "display"   =>  array("en-GB" =>  "posted")
251 251
         );
252
-        $verbs['published'] = array(
252
+        $verbs[ 'published' ] = array(
253 253
             "id"        =>  "http://curatr3.com/define/verb/published",
254
-            "display"   =>  array( "en-GB" =>  "published" )
254
+            "display"   =>  array("en-GB" =>  "published")
255 255
         );
256
-        $verbs['read'] = array(
256
+        $verbs[ 'read' ] = array(
257 257
             "id"        =>  "http://curatr3.com/define/verb/read",
258
-            "display"   =>  array( "en-GB" =>  "read" )
258
+            "display"   =>  array("en-GB" =>  "read")
259 259
         );
260
-        $verbs['liked'] = array(
260
+        $verbs[ 'liked' ] = array(
261 261
             "id"        =>  "http://curatr3.com/define/verb/liked",
262
-            "display"   =>  array( "en-GB" =>  "liked" )
262
+            "display"   =>  array("en-GB" =>  "liked")
263 263
         );
264
-        $verbs['bookmarked'] = array(
264
+        $verbs[ 'bookmarked' ] = array(
265 265
             "id"        =>  "http://curatr3.com/define/verb/bookmarked",
266
-            "display"   =>  array( "en-GB" =>  "bookmarked" )
266
+            "display"   =>  array("en-GB" =>  "bookmarked")
267 267
         );
268
-        $verbs['earned'] = array(
268
+        $verbs[ 'earned' ] = array(
269 269
             "id"        =>  "http://curatr3.com/define/verb/earned",
270
-            "display"   =>  array( "en-GB" =>  "earned" )
270
+            "display"   =>  array("en-GB" =>  "earned")
271 271
         );
272
-        $verbs['badge_earned'] = array(
272
+        $verbs[ 'badge_earned' ] = array(
273 273
             "id"        =>  "http://specification.openbadges.org/xapi/verbs/earned",
274
-            "display"   =>  array( "en-GB" =>  "earned" )
274
+            "display"   =>  array("en-GB" =>  "earned")
275 275
         );
276
-        $verbs['login'] = array(
276
+        $verbs[ 'login' ] = array(
277 277
             "id"        =>  "https://brindlewaye.com/xAPITerms/verbs/loggedin/",
278
-            "display"   =>  array(  "en-GB" =>  "logged in to" )
278
+            "display"   =>  array("en-GB" =>  "logged in to")
279 279
         );
280
-        $verbs['logout'] = array(
280
+        $verbs[ 'logout' ] = array(
281 281
             "id"        =>  "http://curatr3.com/define/verb/logout",
282
-            "display"   =>  array(  "en-GB" =>  "logged out of" )
282
+            "display"   =>  array("en-GB" =>  "logged out of")
283 283
         );
284
-        $verbs['edited'] = array(
284
+        $verbs[ 'edited' ] = array(
285 285
             "id"        =>  "http://curatr3.com/define/verb/edited",
286
-            "display"   =>  array( "en-GB" =>  "edited" )
286
+            "display"   =>  array("en-GB" =>  "edited")
287 287
         );
288
-        $verbs['uploaded'] = array(
288
+        $verbs[ 'uploaded' ] = array(
289 289
             "id"        =>  "http://curatr3.com/define/verb/uploaded",
290
-            "display"   =>  array( "en-GB" =>  "uploaded" )
290
+            "display"   =>  array("en-GB" =>  "uploaded")
291 291
         );
292
-        $verbs['accessed'] = array(
292
+        $verbs[ 'accessed' ] = array(
293 293
             "id"        =>  "http://activitystrea.ms/schema/1.0/access",
294
-            "display"   =>  array( "en-GB" =>  "accessed" )
294
+            "display"   =>  array("en-GB" =>  "accessed")
295 295
         );
296
-        $verbs['voted-up'] = array(
296
+        $verbs[ 'voted-up' ] = array(
297 297
             "id"        =>  "http://curatr3.com/define/verb/voted-up",
298
-            "display"   =>  array(  "en-GB" =>  "voted up" )
298
+            "display"   =>  array("en-GB" =>  "voted up")
299 299
         );
300
-        $verbs['voted-down'] = array(
300
+        $verbs[ 'voted-down' ] = array(
301 301
             "id"        =>  "http://curatr3.com/define/verb/voted-down",
302
-            "display"   =>  array(  "en-GB" =>  "voted down" )
302
+            "display"   =>  array("en-GB" =>  "voted down")
303 303
         );
304
-        $verbs['flag-as-inappropriate'] = array(
304
+        $verbs[ 'flag-as-inappropriate' ] = array(
305 305
             "id"        =>  "http://activitystrea.ms/schema/1.0/flag-as-inappropriate",
306
-            "display"   =>  array( "en-GB" =>  "flagged as inappropriate" )
306
+            "display"   =>  array("en-GB" =>  "flagged as inappropriate")
307 307
         );
308
-        $verbs['join'] = array(
308
+        $verbs[ 'join' ] = array(
309 309
             "id"        =>  "http://activitystrea.ms/schema/1.0/join",
310
-            "display"   =>  array( "en-GB" =>  "joined" )
310
+            "display"   =>  array("en-GB" =>  "joined")
311 311
         );
312
-        $verbs['leave'] = array(
312
+        $verbs[ 'leave' ] = array(
313 313
             "id"        =>  "http://activitystrea.ms/schema/1.0/leave",
314
-            "display"   =>  array( "en-GB" =>  "left" )
314
+            "display"   =>  array("en-GB" =>  "left")
315 315
         );
316
-        $verbs['opened'] = array(
316
+        $verbs[ 'opened' ] = array(
317 317
             "id"        =>  "http://activitystrea.ms/schema/1.0/open",
318
-            "display"   =>  array( "en-GB" =>  "opened" )
318
+            "display"   =>  array("en-GB" =>  "opened")
319 319
         );
320 320
 
321
-        return self::checkKey( $verbs, $key, $verbs['experienced']);
321
+        return self::checkKey($verbs, $key, $verbs[ 'experienced' ]);
322 322
     }
323 323
 
324 324
     /**
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      * @return array
332 332
      *
333 333
      */
334
-    public static function createObject( $id, $name=null, $description=null, $type=null, $extensions = array() )
334
+    public static function createObject($id, $name = null, $description = null, $type = null, $extensions = array())
335 335
     {
336 336
         $object = array(
337 337
         'objectType'    => 'Activity',
@@ -341,27 +341,27 @@  discard block
 block discarded – undo
341 341
         $definition = array();
342 342
 
343 343
         if (!empty($name)) {
344
-        $definition['name'] = [
344
+        $definition[ 'name' ] = [
345 345
             'en-GB' => $name
346 346
         ];
347 347
         }
348 348
 
349
-        if( !empty($description)){
350
-            $definition['description'] = [
349
+        if (!empty($description)) {
350
+            $definition[ 'description' ] = [
351 351
             'en-GB'=>$description
352 352
         ];
353 353
         }
354 354
 
355
-        if( !empty($type)){
356
-        $definition['type'] = $type;
355
+        if (!empty($type)) {
356
+        $definition[ 'type' ] = $type;
357 357
         }
358 358
 
359
-        if( !empty($extensions) ){
360
-        $definition['extensions'] = $extensions;
359
+        if (!empty($extensions)) {
360
+        $definition[ 'extensions' ] = $extensions;
361 361
         }
362 362
 
363 363
         if (!empty($definition)) {
364
-        $object['definition'] = $definition;
364
+        $object[ 'definition' ] = $definition;
365 365
         }
366 366
 
367 367
         return $object;
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
 
371 371
 
372 372
   public function sendRequests() {
373
-    foreach( $this->endpoints as $name => $ep ){
373
+    foreach ($this->endpoints as $name => $ep) {
374 374
 
375 375
       $username = $ep->username;
376 376
       $password = $ep->key;
377 377
       $url = $ep->url;
378 378
 
379
-      if(substr($url, -1) !== '/') {
379
+      if (substr($url, -1) !== '/') {
380 380
         $url .= '/';
381 381
       }
382 382
 
@@ -395,74 +395,74 @@  discard block
 block discarded – undo
395 395
   * Send the request to all end points defined in the endpoints array
396 396
   * @return array An array of all requests sent and their responses
397 397
   */
398
-    public function sendRequestsOld(){
398
+    public function sendRequestsOld() {
399 399
       $error = $this->checkError();
400
-      if( $error ) return false;
400
+      if ($error) return false;
401 401
 
402 402
       $results = array();
403 403
 
404 404
 
405
-      foreach( $this->endpoints as $name => $ep ){
405
+      foreach ($this->endpoints as $name => $ep) {
406 406
 
407 407
           $username = $ep->username;
408 408
           $password = $ep->key;
409 409
           $url = $ep->url;
410
-          $auth = base64_encode( $username.':'.$password );
410
+          $auth = base64_encode($username . ':' . $password);
411 411
 
412 412
           $result = $this->make_request($auth, $url, $this->statement);
413 413
           $error = false;
414 414
           $error_type = "";
415 415
           $body = "";
416 416
 
417
-          if( isset($result['error']) ){
417
+          if (isset($result[ 'error' ])) {
418 418
             $error = true;
419 419
             $error_type = "cURL error";
420 420
           } else {
421 421
 
422
-            $body = isset($result['body']) ? json_decode($result['body']) : "";
422
+            $body = isset($result[ 'body' ]) ? json_decode($result[ 'body' ]) : "";
423 423
 
424
-            if( isset($body->success) ){
425
-              if( $body->success == false ){
424
+            if (isset($body->success)) {
425
+              if ($body->success == false) {
426 426
                 $error = true;
427 427
                 $error_type = "LRS returned success as false";
428 428
               }
429 429
             }
430 430
 
431
-            if( isset($body->error) ){
432
-              if( $body->error == true ){
431
+            if (isset($body->error)) {
432
+              if ($body->error == true) {
433 433
                 $error = true;
434 434
                 $error_type = "LRS returned error as true";
435 435
               }
436 436
             }
437
-            if( isset($result['status']) ){
438
-              $status = $result['status'];
437
+            if (isset($result[ 'status' ])) {
438
+              $status = $result[ 'status' ];
439 439
 
440
-              switch( intval($status) ){
440
+              switch (intval($status)) {
441 441
                 case 400:
442 442
                 case 404:
443 443
                 case 500:
444 444
                   $error = true;
445
-                  $error_type = "LRS returned HTTP code ".$status;
445
+                  $error_type = "LRS returned HTTP code " . $status;
446 446
                 break;
447 447
               }
448 448
             }
449 449
           }
450 450
 
451
-          if( $error ){
452
-            $this->log->error( 'Statement Failed', array(
451
+          if ($error) {
452
+            $this->log->error('Statement Failed', array(
453 453
               'curl_result' =>  $result,
454 454
               'type'        =>  $error_type,
455 455
               'url'         =>  $ep->url,
456 456
               'statement'   =>  $this->statement
457 457
             ));
458 458
           } else {
459
-            $this->log->info( 'Sent', array(
459
+            $this->log->info('Sent', array(
460 460
               'url'         =>  $ep->url,
461 461
               'statement'   =>  $this->statement
462 462
             ));
463 463
           }
464 464
 
465
-          $results[$url] = $body;
465
+          $results[ $url ] = $body;
466 466
       }
467 467
 
468 468
 
@@ -480,35 +480,35 @@  discard block
 block discarded – undo
480 480
   * @param array $statement The statement to be encoded
481 481
   * @return boolean/array Returns false on fail, array of details on success
482 482
   */
483
-  public function make_request( $auth, $url, $statement ) {
483
+  public function make_request($auth, $url, $statement) {
484 484
 
485
-    $headers =   array(
486
-      'Authorization: Basic '.$auth,
485
+    $headers = array(
486
+      'Authorization: Basic ' . $auth,
487 487
       'Content-Type: application/json; charset=UTF-8',
488 488
       'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
489 489
       'X-Experience-API-Version: 1.0.0'
490 490
     );
491 491
 
492
-    if(substr($url, -1) !== '/') {
492
+    if (substr($url, -1) !== '/') {
493 493
       $url .= '/';
494 494
     }
495 495
 
496
-    $ch = curl_init( $url . 'statements' );
497
-    curl_setopt( $ch, CURLOPT_POST, 1);
498
-    curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($statement) );
499
-    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
500
-    curl_setopt( $ch, CURLOPT_HEADER, 1);
501
-    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
502
-    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
496
+    $ch = curl_init($url . 'statements');
497
+    curl_setopt($ch, CURLOPT_POST, 1);
498
+    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($statement));
499
+    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
500
+    curl_setopt($ch, CURLOPT_HEADER, 1);
501
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
502
+    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
503 503
 
504
-    if( substr($url, 0, 5) == "https" ){
504
+    if (substr($url, 0, 5) == "https") {
505 505
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
506 506
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
507
-      curl_setopt ($ch, CURLOPT_CAINFO, storage_path()."/cacert.pem");
507
+      curl_setopt($ch, CURLOPT_CAINFO, storage_path() . "/cacert.pem");
508 508
     }
509 509
 
510
-    $response = curl_exec( $ch );
511
-    if( $response === false ){
510
+    $response = curl_exec($ch);
511
+    if ($response === false) {
512 512
       return array('error'=>true, 'curl_error'=>curl_error($ch));
513 513
     } else {
514 514
       $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
@@ -523,23 +523,23 @@  discard block
 block discarded – undo
523 523
     }
524 524
   }
525 525
 
526
-    private function checkError(){
527
-        if( empty($this->statement) ){
526
+    private function checkError() {
527
+        if (empty($this->statement)) {
528 528
             $this->error("No data set");
529 529
             return true;
530 530
         }
531 531
 
532
-        if( !isset($this->statement['actor']) ){
532
+        if (!isset($this->statement[ 'actor' ])) {
533 533
             $this->error("No actor set");
534 534
             return true;
535 535
         }
536 536
 
537
-        if( !isset($this->statement['verb']) ){
537
+        if (!isset($this->statement[ 'verb' ])) {
538 538
             $this->error("No verb set");
539 539
             return true;
540 540
         }
541 541
 
542
-        if( !isset($this->statement['object']) ){
542
+        if (!isset($this->statement[ 'object' ])) {
543 543
             $this->error("No object set");
544 544
             return true;
545 545
         }
@@ -547,15 +547,15 @@  discard block
 block discarded – undo
547 547
         return false;
548 548
     }
549 549
 
550
-    private function error( $message ){
551
-        $this->log->error( "Statement Generator Error: ".$message );
550
+    private function error($message) {
551
+        $this->log->error("Statement Generator Error: " . $message);
552 552
     }
553 553
 
554 554
     /**
555 555
      * We will probably move this to the db, or hook into an existing service?
556 556
      *
557 557
      **/
558
-    private static function returnAvailableVerbs(){
558
+    private static function returnAvailableVerbs() {
559 559
         return array(
560 560
             'answered',
561 561
             'asked',
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
             'voided');
585 585
     }
586 586
 
587
-    public static function makeEndpoint( $url, $username, $password ){
587
+    public static function makeEndpoint($url, $username, $password) {
588 588
         $ep = new \stdClass;
589 589
         $ep->url = $url;
590 590
         $ep->username = $username;
Please login to merge, or discard this patch.
src/LearningLocker/Statements/StatementInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
 
13 13
 interface StatementInterface {
14 14
   function getAuthCredentials();
15
-  function send( Agent $agent, $verb, $object, Carbon $timestamp=null, Context $context, Result $result );
16
-  function makeStatement( Agent $agent, Verb $verb, $object, Carbon $timestamp, Context $context, Result $result );
15
+  function send(Agent $agent, $verb, $object, Carbon $timestamp = null, Context $context, Result $result);
16
+  function makeStatement(Agent $agent, Verb $verb, $object, Carbon $timestamp, Context $context, Result $result);
17 17
 
18 18
   function getVerb($id, $display);
19 19
 
Please login to merge, or discard this patch.
src/LearningLocker/API/APIHandler.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
                 'auth' => $this->auth(),
19 19
                 'headers' => $this->headers()
20 20
             ]);
21
-            if ( $response->getStatusCode() === 404 )
21
+            if ($response->getStatusCode() === 404)
22 22
                 throw new ClientException(404);
23 23
 
24 24
             return $response->getBody()->getContents();
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
                 'headers' => $this->headers(),
37 37
                 'body' => $data
38 38
             ]);
39
-            if ( $response->getStatusCode() === 404 )
39
+            if ($response->getStatusCode() === 404)
40 40
                 throw new ClientException(404);
41 41
 
42 42
             return $response->getBody()->getContents();
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                 'auth' => $this->auth(),
53 53
                 'headers' => $this->headers()
54 54
             ]);
55
-            if ( $response->getStatusCode() === 404 )
55
+            if ($response->getStatusCode() === 404)
56 56
                 throw new ClientException(404);
57 57
 
58 58
             return $response->getBody()->getContents();
@@ -76,22 +76,22 @@  discard block
 block discarded – undo
76 76
         }
77 77
     }
78 78
 
79
-    public function select($selected = [], $response)
79
+    public function select($selected = [ ], $response)
80 80
     {
81
-        if (!is_array($selected) || !$response)  {
82
-            $error = [ "error" => "Select must be an array."];
81
+        if (!is_array($selected) || !$response) {
82
+            $error = [ "error" => "Select must be an array." ];
83 83
             return json_encode($error);
84 84
         }
85 85
 
86 86
         if ($selected) {
87 87
             $response = (array) json_decode($response);
88
-            $items = [];
88
+            $items = [ ];
89 89
 
90
-            foreach($selected as $select) {
90
+            foreach ($selected as $select) {
91 91
                 $search = array_key_exists($select, $response);
92 92
 
93 93
                 if ($search === true) {
94
-                    $items[$select] = $response[$select];
94
+                    $items[ $select ] = $response[ $select ];
95 95
                 }
96 96
             }
97 97
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
                 return true;
118 118
             }
119 119
 
120
-            if ( $response->getStatusCode() === 404 )
120
+            if ($response->getStatusCode() === 404)
121 121
                 throw new ClientException(404);
122 122
 
123 123
             return $response->getBody()->getContents();
Please login to merge, or discard this patch.
src/LearningLocker/API.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,11 +62,11 @@
 block discarded – undo
62 62
   public function isDomainAvailable($domain) {
63 63
     try {
64 64
       $url = trim($domain, '/') . '/api';
65
-      $request = $this->getClient()->get($url, ['timeout' => 1]);
66
-      if(!$request) {
65
+      $request = $this->getClient()->get($url, [ 'timeout' => 1 ]);
66
+      if (!$request) {
67 67
         return false;
68 68
       }
69
-      if($request->getStatusCode() === 200) {
69
+      if ($request->getStatusCode() === 200) {
70 70
         return true;
71 71
       }
72 72
     } catch (Exception $e) {
Please login to merge, or discard this patch.
src/LearningLocker/Organisation/Organisation.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
    */
44 44
   public function id() {
45 45
     $response = $this->get();
46
-    if($response) {
47
-      $id = $response[0]['_id'];
46
+    if ($response) {
47
+      $id = $response[ 0 ][ '_id' ];
48 48
       $setSetting = LLService::create($this->org, LLService::LL_ID)->setSetting(LLService::ORGANISATION_ID, $id);
49 49
       return $id;
50 50
     }
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
   public function name()
61 61
   {
62 62
     $response = $this->get();
63
-    if($response) {
64
-      $name = $response[0]['name'];
63
+    if ($response) {
64
+      $name = $response[ 0 ][ 'name' ];
65 65
       $setSetting = LLService::create($this->org, LLService::LL_ID)->setSetting(LLService::ORGANISATION, $name);
66 66
       return $name;
67 67
     }
Please login to merge, or discard this patch.