Completed
Push — master ( e89277...1caf4d )
by Patrick
03:08
created
Auth/class.GoogleAuthenticator.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
     public function __construct($params)
11 11
     {
12 12
         parent::__construct($params);
13
-        if(!isset($params['client_secrets_path']))
13
+        if (!isset($params['client_secrets_path']))
14 14
         {
15 15
             throw new \Exception('Missing required parameter client_secrets_path!');
16 16
         }
17
-        if(!isset($params['redirect_url']))
17
+        if (!isset($params['redirect_url']))
18 18
         {
19 19
             $params['redirect_url'] = 'https://'.$_SERVER['HTTP_HOST'].'/oauth2callback.php?src=google';
20 20
         }
@@ -34,21 +34,21 @@  discard block
 block discarded – undo
34 34
     public function authenticate($code, &$currentUser = false)
35 35
     {
36 36
         $googleUser = false;
37
-        try{
37
+        try {
38 38
             $this->client->authenticate($code);
39 39
             $this->token = $this->client->getAccessToken();
40 40
             \FlipSession::setVar('GoogleToken', $this->token);
41 41
             $oauth2Service = new \Google_Service_Oauth2($this->client);
42 42
             $googleUser = $oauth2Service->userinfo->get();
43
-        } catch(\Exception $ex) {
43
+        } catch (\Exception $ex) {
44 44
             return self::LOGIN_FAILED;
45 45
         }
46 46
 
47 47
         $auth = \AuthProvider::getInstance();
48 48
         $localUsers = $auth->getUsersByFilter(new \Data\Filter('mail eq '.$googleUser->email));
49
-        if($localUsers !== false && isset($localUsers[0]))
49
+        if ($localUsers !== false && isset($localUsers[0]))
50 50
         {
51
-            if($localUsers[0]->canLoginWith('google.com'))
51
+            if ($localUsers[0]->canLoginWith('google.com'))
52 52
             {
53 53
                 $auth->impersonateUser($localUsers[0]);
54 54
                 return self::SUCCESS;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             $user->setLastName($googleUser->familyName);
65 65
             $user->addLoginProvider('google.com');
66 66
             $ret = $auth->activatePendingUser($user);
67
-            if($ret === false)
67
+            if ($ret === false)
68 68
             {
69 69
                  throw new \Exception('Unable to create user! '.$res);
70 70
             }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
     public function getUser($data = false)
76 76
     {
77
-        if($data === false)
77
+        if ($data === false)
78 78
         {
79 79
             $data = $this->token;
80 80
         }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             $profileUser['displayName'] = $googleUser->name;
90 90
             $profileUser['jpegPhoto'] = base64_encode(file_get_contents($googleUser->picture));
91 91
             return $profileUser;
92
-        } catch(\Exception $e)
92
+        } catch (\Exception $e)
93 93
         {
94 94
             return false;
95 95
         }
Please login to merge, or discard this patch.
Auth/OAuth2/class.OAuth2Authenticator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 namespace Auth\OAuth2;
15 15
 
16 16
 /** Only load the HTTPFul bootstrap if it isn't already loaded*/
17
-if(!class_exists('Httpful\Request'))
17
+if (!class_exists('Httpful\Request'))
18 18
 {
19 19
     require('/var/www/common/libs/httpful/bootstrap.php');
20 20
 }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     public function __construct($params)
38 38
     {
39 39
         parent::__construct($params);
40
-        if(!isset($params['redirect_url']))
40
+        if (!isset($params['redirect_url']))
41 41
         {
42 42
             $this->redirect_uri = 'https://'.$_SERVER['HTTP_HOST'].'/oauth/callbacks/'.$this->getHostName();
43 43
         }
@@ -115,21 +115,21 @@  discard block
 block discarded – undo
115 115
     public function authenticate($params, &$current_user)
116 116
     {
117 117
         $resp = $this->doAuthPost($params);
118
-        if($resp->hasErrors())
118
+        if ($resp->hasErrors())
119 119
         {
120 120
             return self::LOGIN_FAILED; 
121 121
         }
122 122
         \FlipSession::setVar('OAuthToken', $resp->body);
123 123
         $user = $this->getUserFromToken($resp->body);
124
-        if($user === false)
124
+        if ($user === false)
125 125
         {
126 126
             return self::LOGIN_FAILED;
127 127
         }
128 128
         $auth = \AuthProvider::getInstance();
129 129
         $local_users = $auth->getUsersByFilter(new \Data\Filter('mail eq '.$user->getEmail()));
130
-        if($local_users !== false && isset($local_users[0]))
130
+        if ($local_users !== false && isset($local_users[0]))
131 131
         {
132
-            if($local_users[0]->canLoginWith($this->getHostName()))
132
+            if ($local_users[0]->canLoginWith($this->getHostName()))
133 133
             {
134 134
                 $auth->impersonateUser($local_users[0]);
135 135
                 return self::SUCCESS;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             return self::ALREADY_PRESENT;
139 139
         }
140 140
         $ret = $auth->activatePendingUser($user);
141
-        if($ret === false)
141
+        if ($ret === false)
142 142
         {
143 143
             throw new \Exception('Unable to create user! '.$res);
144 144
         }
Please login to merge, or discard this patch.
Auth/OAuth2/class.GitLabAuthenticator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
     public function getUserFromToken($token)
32 32
     {
33
-        if($token === false)
33
+        if ($token === false)
34 34
         {
35 35
             $token = \FlipSession::getVar('OAuthToken');
36 36
         }
Please login to merge, or discard this patch.
Auth/OAuth2/class.FlipsideAuthenticator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function getUserFromToken($token)
27 27
     {
28
-        if($token === false)
28
+        if ($token === false)
29 29
         {
30 30
             $token = \FlipSession::getVar('OAuthToken');
31 31
         }
32 32
         $resp = \Httpful\Request::get('https://api.github.com/user')->addHeader('Authorization', 'token '.$token['access_token'])->send();
33 33
         $github_user = $resp->body;
34 34
         $user = new \Auth\PendingUser();
35
-        if(isset($github_user->name))
35
+        if (isset($github_user->name))
36 36
         {
37 37
             $name = explode(' ', $github_user->name);
38 38
             $user->setGivenName($name[0]);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public function login($username, $password)
48 48
     {
49 49
         $resp = \Httpful\Request::post('https://profiles.test.burningflipside.com/api/v1/login?username='.urlencode($username).'&password='.urlencode($password))->send();
50
-        if($resp->hasErrors())
50
+        if ($resp->hasErrors())
51 51
         {
52 52
             return false;
53 53
         }
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 
59 59
     public function isLoggedIn($data)
60 60
     {
61
-        if(isset($this->user))
61
+        if (isset($this->user))
62 62
         {
63 63
             return true;
64 64
         }
65
-        if(isset($data['res']))
65
+        if (isset($data['res']))
66 66
         {
67 67
             return $data['res'];
68 68
         }
Please login to merge, or discard this patch.
Auth/OAuth2/class.GitHubAuthenticator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@
 block discarded – undo
30 30
 
31 31
     public function getUserFromToken($token)
32 32
     {
33
-        if($token === false)
33
+        if ($token === false)
34 34
         {
35 35
             $token = \FlipSession::getVar('OAuthToken');
36 36
         }
37 37
         $resp = \Httpful\Request::get('https://api.github.com/user')->addHeader('Authorization', 'token '.$token['access_token'])->send();
38 38
         $github_user = $resp->body;
39 39
         $user = new \Auth\PendingUser();
40
-        if(isset($github_user->name))
40
+        if (isset($github_user->name))
41 41
         {
42 42
             $name = explode(' ', $github_user->name);
43 43
             $user->setGivenName($name[0]);
Please login to merge, or discard this patch.
Auth/class.NullAuthenticator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 
11 11
     public function isLoggedIn($data)
12 12
     {
13
-        if(isset($data['res']))
13
+        if (isset($data['res']))
14 14
         {
15 15
             return $data['res'];
16 16
         }
Please login to merge, or discard this patch.
Auth/class.Authenticator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      *
103 103
      * @SuppressWarnings("UnusedFormalParameter")
104 104
      */
105
-    public function getGroupsByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false)
105
+    public function getGroupsByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false)
106 106
     {
107 107
         return false;
108 108
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      *
121 121
      * @SuppressWarnings("UnusedFormalParameter")
122 122
      */
123
-    public function getUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false)
123
+    public function getUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false)
124 124
     {
125 125
         return false;
126 126
     }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      *
139 139
      * @SuppressWarnings("UnusedFormalParameter")
140 140
      */
141
-    public function getPendingUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false)
141
+    public function getPendingUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false)
142 142
     {
143 143
         return false;
144 144
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     public function getActiveUserCount()
152 152
     {
153 153
         $users = $this->getUsersByFilter(false);
154
-        if($users === false)
154
+        if ($users === false)
155 155
         {
156 156
             return 0;
157 157
         }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     public function getPendingUserCount()
167 167
     {
168 168
         $users = $this->getPendingUsersByFilter(false);
169
-        if($users === false)
169
+        if ($users === false)
170 170
         {
171 171
             return 0;
172 172
         }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     public function getGroupCount()
182 182
     {
183 183
         $groups = $this->getGroupsByFilter(false);
184
-        if($groups === false)
184
+        if ($groups === false)
185 185
         {
186 186
             return 0;
187 187
         }
Please login to merge, or discard this patch.
Auth/class.User.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -128,26 +128,26 @@  discard block
 block discarded – undo
128 128
     function getTitleNames()
129 129
     {
130 130
         $titles = $this->getTitles();
131
-        if($titles === false)
131
+        if ($titles === false)
132 132
         {
133 133
             return false;
134 134
         }
135
-        if(self::$titlenames === null)
135
+        if (self::$titlenames === null)
136 136
         {
137 137
             $dataSet = \DataSetFactory::get_data_set('profiles');
138 138
             $dataTable = $dataSet['position'];
139 139
             $titlenames = $dataTable->read();
140 140
             self::$titlenames = array();
141 141
             $count = count($titlenames);
142
-            for($i = 0; $i < $count; $i++)
142
+            for ($i = 0; $i < $count; $i++)
143 143
             {
144 144
                 self::$titlenames[$titlenames[$i]['short_name']] = $titlenames[$i];
145 145
             }
146 146
         }
147 147
         $count = count($titles);
148
-        for($i = 0; $i < $count; $i++)
148
+        for ($i = 0; $i < $count; $i++)
149 149
         {
150
-            if(isset(self::$titlenames[$titles[$i]]))
150
+            if (isset(self::$titlenames[$titles[$i]]))
151 151
             {
152 152
                 $title = self::$titlenames[$titles[$i]];
153 153
                 $titles[$i] = $title['name'];
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
     function canLoginWith($provider)
281 281
     {
282 282
         $hosts = $this->getLoginProviders();
283
-        if($hosts === false) return false;
283
+        if ($hosts === false) return false;
284 284
         $count = count($hosts);
285
-        for($i = 0; $i < $count; $i++)
285
+        for ($i = 0; $i < $count; $i++)
286 286
         {
287
-            if(strcasecmp($hosts[$i], $provider) === 0) return true;
287
+            if (strcasecmp($hosts[$i], $provider) === 0) return true;
288 288
         }
289 289
         return false;
290 290
     }
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
      */
309 309
     function isProfileComplete()
310 310
     {
311
-        if($this->getCountry() === false    || $this->getAddress() === false ||
311
+        if ($this->getCountry() === false || $this->getAddress() === false ||
312 312
            $this->getPostalCode() === false || $this->getCity() === false ||
313
-           $this->getState() === false      || $this->getPhoneNumber() === false)
313
+           $this->getState() === false || $this->getPhoneNumber() === false)
314 314
         {
315 315
             return false;
316 316
         }
@@ -354,17 +354,17 @@  discard block
 block discarded – undo
354 354
      *
355 355
      * @return true|false true if the user's password was changed, false otherwise
356 356
      */
357
-    function change_pass($oldpass, $newpass, $isHash=false)
357
+    function change_pass($oldpass, $newpass, $isHash = false)
358 358
     {
359
-        if($isHash === false && $this->validate_password($oldpass) === false)
359
+        if ($isHash === false && $this->validate_password($oldpass) === false)
360 360
         {
361 361
             throw new \Exception('Invalid Password!', 3);
362 362
         }
363
-        if($isHash === true && $this->validate_reset_hash($oldpass) === false)
363
+        if ($isHash === true && $this->validate_reset_hash($oldpass) === false)
364 364
         {
365 365
             throw new \Exception('Invalid Reset Hash!', 3);
366 366
         }
367
-        if($this->setPass($newpass) === false)
367
+        if ($this->setPass($newpass) === false)
368 368
         {
369 369
             throw new \Exception('Unable to set password!', 6);
370 370
         }
@@ -602,99 +602,99 @@  discard block
 block discarded – undo
602 602
         $auth = \AuthProvider::getInstance();
603 603
         $ldap = $auth->getAuthenticator('Auth\LDAPAuthenticator');
604 604
         $ldap->get_and_bind_server(true);
605
-        if(isset($data->oldpass) && isset($data->password))
605
+        if (isset($data->oldpass) && isset($data->password))
606 606
         {
607 607
             $this->change_pass($data->oldpass, $data->password);
608 608
             unset($data->oldpass);
609 609
             unset($data->password);
610 610
         }
611
-        else if(isset($data->hash) && isset($data->password))
611
+        else if (isset($data->hash) && isset($data->password))
612 612
         {
613 613
             $this->change_pass($data->hash, $data->password, true);
614 614
             return;
615 615
         }
616
-        if(isset($data->displayName))
616
+        if (isset($data->displayName))
617 617
         {
618 618
             $this->setDisplayName($data->displayName);
619 619
             unset($data->displayName);
620 620
         }
621
-        if(isset($data->givenName))
621
+        if (isset($data->givenName))
622 622
         {
623 623
             $this->setGivenName($data->givenName);
624 624
             unset($data->givenName);
625 625
         }
626
-        if(isset($data->jpegPhoto))
626
+        if (isset($data->jpegPhoto))
627 627
         {
628 628
             $this->setPhoto(base64_decode($data->jpegPhoto));
629 629
             unset($data->jpegPhoto);
630 630
         }
631
-        if(isset($data->mail))
631
+        if (isset($data->mail))
632 632
         {
633
-            if($data->mail !== $this->getEmail())
633
+            if ($data->mail !== $this->getEmail())
634 634
             {
635 635
                 throw new \Exception('Unable to change email!');
636 636
             }
637 637
             unset($data->mail);
638 638
         }
639
-        if(isset($data->uid))
639
+        if (isset($data->uid))
640 640
         {
641
-            if($data->uid !== $this->getUid())
641
+            if ($data->uid !== $this->getUid())
642 642
             {
643 643
                 throw new \Exception('Unable to change uid!');
644 644
             }
645 645
             unset($data->uid);
646 646
         }
647
-        if(isset($data->mobile))
647
+        if (isset($data->mobile))
648 648
         {
649 649
             $this->setPhoneNumber($data->mobile);
650 650
             unset($data->mobile);
651 651
         }
652
-        if(isset($data->o))
652
+        if (isset($data->o))
653 653
         {
654 654
             $this->setOrganization($data->o);
655 655
             unset($data->o);
656 656
         }
657
-        if(isset($data->title))
657
+        if (isset($data->title))
658 658
         {
659 659
             $this->setTitles($data->title);
660 660
             unset($data->title);
661 661
         }
662
-        if(isset($data->st))
662
+        if (isset($data->st))
663 663
         {
664 664
             $this->setState($data->st);
665 665
             unset($data->st);
666 666
         }
667
-        if(isset($data->l))
667
+        if (isset($data->l))
668 668
         {
669 669
             $this->setCity($data->l);
670 670
             unset($data->l);
671 671
         }
672
-        if(isset($data->sn))
672
+        if (isset($data->sn))
673 673
         {
674 674
             $this->setLastName($data->sn);
675 675
             unset($data->sn);
676 676
         }
677
-        if(isset($data->cn))
677
+        if (isset($data->cn))
678 678
         {
679 679
             $this->setNickName($data->cn);
680 680
             unset($data->cn);
681 681
         }
682
-        if(isset($data->postalAddress))
682
+        if (isset($data->postalAddress))
683 683
         {
684 684
             $this->setAddress($data->postalAddress);
685 685
             unset($data->postalAddress);
686 686
         }
687
-        if(isset($data->postalCode))
687
+        if (isset($data->postalCode))
688 688
         {
689 689
             $this->setPostalCode($data->postalCode);
690 690
             unset($data->postalCode);
691 691
         }
692
-        if(isset($data->c))
692
+        if (isset($data->c))
693 693
         {
694 694
             $this->setCountry($data->c);
695 695
             unset($data->c);
696 696
         }
697
-        if(isset($data->ou))
697
+        if (isset($data->ou))
698 698
         {
699 699
             $this->setOrganizationUnits($data->ou);
700 700
             unset($data->ou);
@@ -749,13 +749,13 @@  discard block
 block discarded – undo
749 749
     public function getVcard()
750 750
     {
751 751
         $ret = "BEGIN:VCARD\nVERSION:2.1\n";
752
-        $ret.= 'N:'.$this->getLastName().';'.$this->getGivenName()."\n";
753
-        $ret.= 'FN:'.$this->getGivenName()."\n";
754
-        $ret.= 'TITLE:'.implode(',', $this->getTitles())."\n";
755
-        $ret.= "ORG: Austin Artistic Reconstruction\n";
756
-        $ret.= 'TEL;TYPE=MOBILE,VOICE:'.$this->getPhoneNumber()."\n";
757
-        $ret.= 'EMAIL;TYPE=PREF,INTERNET:'.$this->getEmail()."\n";
758
-        $ret.= "END:VCARD\n";
752
+        $ret .= 'N:'.$this->getLastName().';'.$this->getGivenName()."\n";
753
+        $ret .= 'FN:'.$this->getGivenName()."\n";
754
+        $ret .= 'TITLE:'.implode(',', $this->getTitles())."\n";
755
+        $ret .= "ORG: Austin Artistic Reconstruction\n";
756
+        $ret .= 'TEL;TYPE=MOBILE,VOICE:'.$this->getPhoneNumber()."\n";
757
+        $ret .= 'EMAIL;TYPE=PREF,INTERNET:'.$this->getEmail()."\n";
758
+        $ret .= "END:VCARD\n";
759 759
         return $ret;
760 760
     }
761 761
 }
Please login to merge, or discard this patch.
class.FlipREST.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     private function getUserFromSession()
27 27
     {
28
-        if(FlipSession::isLoggedIn())
28
+        if (FlipSession::isLoggedIn())
29 29
         {
30 30
             return FlipSession::getUser();
31 31
         }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         $auth = \AuthProvider::getInstance();
42 42
         $auth->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
43 43
         $user = FlipSession::getUser();
44
-        if($user === false)
44
+        if ($user === false)
45 45
         {
46 46
             $data = substr($header['Authorization'], 6);
47 47
             $userpass = explode(':', base64_decode($data));
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
     private function getUserFromHeader($header)
64 64
     {
65
-        if(strncmp($header, 'Basic', 5) == 0)
65
+        if (strncmp($header, 'Basic', 5) == 0)
66 66
         {
67 67
             return $this->getUserFromBasicAuth($header);
68 68
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     public function call()
73 73
     {
74 74
         // no auth header
75
-        if(!isset($this->headers['Authorization']))
75
+        if (!isset($this->headers['Authorization']))
76 76
         {
77 77
             $this->app->user = $this->getUserFromSession();
78 78
         } 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             $this->app->user = $this->getUserFromHeader($header);
83 83
         }
84 84
 
85
-        if($this->app->user === false)
85
+        if ($this->app->user === false)
86 86
         {
87 87
             $this->app->getLog()->error("No user found for call");
88 88
         }
@@ -96,19 +96,19 @@  discard block
 block discarded – undo
96 96
 {
97 97
     private function fix_encoded_element($key, $value, &$array, $prefix = '')
98 98
     {
99
-        if(is_array($value))
99
+        if (is_array($value))
100 100
         {
101 101
             $array[$key] = implode(';', $value);
102 102
         }
103
-        else if($key === '_id' && is_object($value))
103
+        else if ($key === '_id' && is_object($value))
104 104
         {
105 105
             $array[$key] = $value->{'$id'};
106 106
         }
107
-        else if(is_object($value))
107
+        else if (is_object($value))
108 108
         {
109 109
             $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key;
110 110
         }
111
-        else if(strncmp($value, 'data:', 5) === 0)
111
+        else if (strncmp($value, 'data:', 5) === 0)
112 112
         {
113 113
             $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key;
114 114
         }
@@ -122,40 +122,40 @@  discard block
 block discarded – undo
122 122
         }
123 123
         ob_start();
124 124
         $df = fopen("php://output", 'w');
125
-        if(is_array($array))
125
+        if (is_array($array))
126 126
         {
127 127
             $first = reset($array);
128 128
             $keys = FALSE;
129
-            if(is_array($first))
129
+            if (is_array($first))
130 130
             {
131 131
                 $keys = array_keys($first);
132 132
             }
133
-            else if(is_object($first))
133
+            else if (is_object($first))
134 134
             {
135 135
                 $keys = array_keys(get_object_vars($first));
136 136
             }
137 137
             fputcsv($df, $keys);
138 138
             foreach ($array as $row)
139 139
             {
140
-                if(is_array($row))
140
+                if (is_array($row))
141 141
                 {
142 142
                     $id = $row[$keys[0]];
143
-                    foreach($row as $key=>$value)
143
+                    foreach ($row as $key=>$value)
144 144
                     {
145 145
                         $this->fix_encoded_element($key, $value, $row, '/'.$id);
146 146
                     }
147 147
                     fputcsv($df, $row);
148 148
                 }
149
-                else if(is_object($row))
149
+                else if (is_object($row))
150 150
                 {
151 151
                     $keyName = $keys[0];
152 152
                     $id = $row->$keyName;
153
-                    if(is_object($id))
153
+                    if (is_object($id))
154 154
                     {
155 155
                         $id = $id->{'$id'};
156 156
                     }
157 157
                     $values = get_object_vars($row);
158
-                    foreach($values as $key=>$value)
158
+                    foreach ($values as $key=>$value)
159 159
                     {
160 160
                         $this->fix_encoded_element($key, $value, $values, '/'.$id);
161 161
                     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         {
168 168
             $array = get_object_vars($array);
169 169
             fputcsv($df, array_keys($array));
170
-            foreach($array as $key=>$value)
170
+            foreach ($array as $key=>$value)
171 171
             {
172 172
                 $this->fix_encoded_element($key, $value, $array);
173 173
             }
@@ -185,34 +185,34 @@  discard block
 block discarded – undo
185 185
 
186 186
     public function call()
187 187
     {
188
-        if($this->app->request->isOptions())
188
+        if ($this->app->request->isOptions())
189 189
         {
190 190
             return;
191 191
         }
192 192
         $params = $this->app->request->params();
193 193
         $fmt = null;
194
-        if(isset($params['fmt']))
194
+        if (isset($params['fmt']))
195 195
         {
196 196
             $fmt = $params['fmt'];
197 197
         }
198
-        if($fmt === null && isset($params['$format']))
198
+        if ($fmt === null && isset($params['$format']))
199 199
         {
200 200
             $fmt = $params['$format'];
201
-            if(strstr($fmt, 'odata.streaming=true'))
201
+            if (strstr($fmt, 'odata.streaming=true'))
202 202
             {
203 203
                 $this->app->response->setStatus(406);
204 204
                 return;
205 205
             }
206 206
         }
207
-        if($fmt === null)
207
+        if ($fmt === null)
208 208
         {
209 209
             $mimeType = $this->app->request->headers->get('Accept');
210
-            if(strstr($mimeType, 'odata.streaming=true'))
210
+            if (strstr($mimeType, 'odata.streaming=true'))
211 211
             {
212 212
                 $this->app->response->setStatus(406);
213 213
                 return;
214 214
             }
215
-            switch($mimeType)
215
+            switch ($mimeType)
216 216
             {
217 217
                 case 'text/csv':
218 218
                     $fmt = 'csv';
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
 
233 233
         $this->next->call();
234 234
 
235
-        if($this->app->response->getStatus() == 200 && $this->app->fmt !== 'json')
235
+        if ($this->app->response->getStatus() == 200 && $this->app->fmt !== 'json')
236 236
         {
237 237
             $data = json_decode($this->app->response->getBody());
238 238
             $text = '';
239
-            switch($this->app->fmt)
239
+            switch ($this->app->fmt)
240 240
             {
241 241
                 case 'data-table':
242 242
                     $this->app->response->headers->set('Content-Type', 'application/json');
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
             }
264 264
             $this->app->response->setBody($text);
265 265
         }
266
-        else if($this->app->response->getStatus() == 200)
266
+        else if ($this->app->response->getStatus() == 200)
267 267
         {
268 268
             $this->app->response->headers->set('Content-Type', 'application/json;odata.metadata=none');
269 269
         }
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
         return $this->post($uri, $handler);
294 294
     }
295 295
 
296
-    function get_json_body($array=false)
296
+    function get_json_body($array = false)
297 297
     {
298 298
         return $this->getJsonBody($array);
299 299
     }
300 300
 
301
-    function getJsonBody($array=false)
301
+    function getJsonBody($array = false)
302 302
     {
303 303
         $body = $this->request->getBody();
304 304
         return json_decode($body, $array);
Please login to merge, or discard this patch.