@@ -310,8 +310,8 @@ public static function post(
310310 public static function patch (
311311 string $ id ,
312312 \stdClass $ attributes = null ,
313- \stdClass $ relationships = null )
314- {
313+ \stdClass $ relationships = null
314+ ) {
315315
316316 }
317317
@@ -328,11 +328,10 @@ public static function request(
328328 string $ url ,
329329 string $ method = self ::METHOD_GET ,
330330 \stdClass $ headers = null ,
331- $ data = NULL ,
331+ $ data = null ,
332332 $ flags = self ::REQUEST_EMPTY_FLAG ,
333333 //$accept = 'application/json',
334- $ encoding = NULL
335-
334+ $ encoding = null
336335 ) {
337336 //Extract flags
338337 //Is the request binary
@@ -366,7 +365,7 @@ public static function request(
366365
367366 curl_setopt ($ handle , CURLOPT_URL , $ url );
368367 curl_setopt ($ handle , CURLOPT_HTTPHEADER , $ headersArray );
369- curl_setopt ($ handle , CURLOPT_RETURNTRANSFER , TRUE );
368+ curl_setopt ($ handle , CURLOPT_RETURNTRANSFER , true );
370369 curl_setopt ($ handle , CURLOPT_HEADER , true );
371370
372371 //Set timeout values ( in seconds )
@@ -375,11 +374,11 @@ public static function request(
375374 curl_setopt ($ handle , CURLOPT_NOSIGNAL , 1 );
376375 //Security options
377376 curl_setopt ($ handle , CURLOPT_SSL_VERIFYHOST , 2 );
378- curl_setopt ($ handle , CURLOPT_SSL_VERIFYPEER , FALSE );
377+ curl_setopt ($ handle , CURLOPT_SSL_VERIFYPEER , false );
379378
380379 /*//On binary transfers
381380 if ($binary) {
382- curl_setopt($handle, CURLOPT_BINARYTRANSFER, TRUE );
381+ curl_setopt($handle, CURLOPT_BINARYTRANSFER, true );
383382 }*/
384383
385384 //Switch on HTTP Request method
@@ -391,15 +390,27 @@ public static function request(
391390 curl_setopt ($ handle , CURLOPT_POST , true );
392391 if ($ data && $ form_encoded ) { //Encode fields if required ( URL ENCODED )
393392 curl_setopt (
394- $ handle , CURLOPT_POSTFIELDS , http_build_query ($ data ));
395- } else if ($ data ) {
396- curl_setopt ($ handle , CURLOPT_POSTFIELDS , $ data );
393+ $ handle ,
394+ CURLOPT_POSTFIELDS ,
395+ http_build_query ($ data )
396+ );
397+ } elseif ($ data ) {
398+ curl_setopt (
399+ $ handle ,
400+ CURLOPT_POSTFIELDS ,
401+ $ data
402+ );
397403 }
398404 break ;
399405 case self ::METHOD_PUT : //On METHOD_PUT
400406 curl_setopt ($ handle , CURLOPT_CUSTOMREQUEST , self ::METHOD_PUT );
407+ //todo only if json
401408 if ($ data ) {
402- curl_setopt ($ handle , CURLOPT_POSTFIELDS , json_encode ($ data ));
409+ curl_setopt (
410+ $ handle ,
411+ CURLOPT_POSTFIELDS ,
412+ json_encode ($ data )
413+ );
403414 }
404415 break ;
405416 case self ::METHOD_DELETE : //On METHOD_DELETE
@@ -432,10 +443,10 @@ public static function request(
432443 curl_close ($ handle );
433444
434445 return [
435- $ responseStatusCode ,
436- $ responseHeaders ,
437- json_decode ($ responseBody )
438- ];
446+ $ responseStatusCode ,
447+ $ responseHeaders ,
448+ json_decode ($ responseBody )
449+ ];
439450
440451 /* if (!$response) {
441452 throw new Exception('Error: ' . curl_error($handle));
0 commit comments