Passed
Pull Request — master (#57)
by Stone
03:27
created
Core/Dependency/Cookie.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace Core\Dependency;
4 4
 
5
-class Cookie{
5
+class Cookie {
6 6
 
7 7
     /**
8 8
      * set a cookie
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function deleteCookie(string $name):void
23 23
     {
24
-        setcookie($name, "", time()-3600); //expire the cookie
24
+        setcookie($name, "", time() - 3600); //expire the cookie
25 25
     }
26 26
 
27 27
     /**
Please login to merge, or discard this patch.
App/Controllers/Login.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     private function populateUserFromId(int $userId)
77 77
     {
78 78
         $result = $this->userModel->getUserDetailsById($userId);
79
-        $this->populateUser((array)$result);
79
+        $this->populateUser((array) $result);
80 80
     }
81 81
 
82 82
     /**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function index()
99 99
     {
100
-        if($this->session->isParamSet("user"))
100
+        if ($this->session->isParamSet("user"))
101 101
         {
102 102
             //we are already connected, redirect
103 103
             $this->response->redirect();
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function register()
128 128
     {
129
-        if($this->session->isParamSet("user"))
129
+        if ($this->session->isParamSet("user"))
130 130
         {
131 131
             //we are already connected, redirect
132 132
             $this->response->redirect();
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             }
184 184
 
185 185
             $authUser = $this->userModel->authenticateUser($email, $password);
186
-            if(!$authUser->success)
186
+            if (!$authUser->success)
187 187
             {
188 188
                 $error = true;
189 189
                 $loginErrors->global = $authUser->message;
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
         //we are authenticated here
203 203
 
204 204
         //populate the user object with returned data
205
-        $this->populateUser((array)$authUser->user);
205
+        $this->populateUser((array) $authUser->user);
206 206
 
207 207
         //if the user wanted to be remembered
208
-        if($rememberMe)
208
+        if ($rememberMe)
209 209
         {
210 210
             $this->rememberedLoginModel->setToken(); //generate a new token
211 211
             $rememberMeToken = $this->rememberedLoginModel->rememberMe($this->user->idusers);
212
-            if($rememberMeToken->success)
212
+            if ($rememberMeToken->success)
213 213
             {
214 214
                 //set cookie
215 215
                 $this->cookie->setCookie("rememberMe", $rememberMeToken->token, $rememberMeToken->expiry_timestamp);
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
         $baseUrl = $this->request->getBaseUrl();
293 293
         $redirectUrl = $this->removeFromBeginning($refererUrl, $baseUrl);
294 294
 
295
-        if($redirectUrl === "login/register")
295
+        if ($redirectUrl === "login/register")
296 296
         {
297 297
             //if we were already on the register page, go to home page
298
-            $redirectUrl="";
298
+            $redirectUrl = "";
299 299
         }
300 300
 
301 301
         $this->alertBox->setAlert('Account created, please check your mailbox to activate account');
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     public function disconnect()
309 309
     {
310 310
         $userId = $this->session->get("userId");
311
-        if($userId)
311
+        if ($userId)
312 312
         {
313 313
             $userHash = $this->rememberedLoginModel->getTokenHashFromId($userId);
314 314
             $this->rememberedLoginModel->deleteToken($userHash);
Please login to merge, or discard this patch.
App/Models/RoleModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 use Core\Container;
7 7
 use Core\Model;
8 8
 
9
-class RoleModel extends Model{
9
+class RoleModel extends Model {
10 10
 
11 11
     private $roleTbl;
12 12
 
Please login to merge, or discard this patch.
Core/Modules/Debug.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 use Core\Constant;
6 6
 use \Core\Container;
7 7
 
8
-class Debug extends Module{
8
+class Debug extends Module {
9 9
 
10 10
     /**
11 11
      * Var dump a var
Please login to merge, or discard this patch.
App/Models/UserModel.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         //check if email is valid for sanity
172 172
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
173 173
             $email = htmlspecialchars($email);
174
-            throw new BlogocException("invalid email " . $email);
174
+            throw new BlogocException("invalid email ".$email);
175 175
         }
176 176
         $sql = $this->baseSqlSelect();
177 177
         $sql .= "
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         $this->bind(':roles_idroles', 1); //we set to one, should probably get from database and config
215 215
         $this->execute();
216 216
 
217
-        return (int)$this->dbh->lastInsertId();
217
+        return (int) $this->dbh->lastInsertId();
218 218
     }
219 219
 
220 220
     /**
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     public function updateUser(\stdClass $user)
226 226
     {
227
-        $sql="
227
+        $sql = "
228 228
             UPDATE $this->userTbl
229 229
             SET
230 230
               name=:name,
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
         }
275 275
 
276 276
         if ($this->isAccountPasswordBlocked($user)) {
277
-            $response->message = "too many bad passwords, account is blocked for " . Constant::LOCKOUT_MINUTES . " minutes";
277
+            $response->message = "too many bad passwords, account is blocked for ".Constant::LOCKOUT_MINUTES." minutes";
278 278
             return $response;
279 279
         }
280 280
 
Please login to merge, or discard this patch.
App/Controllers/Admin/Home.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
         $this->onlyUser();
97 97
         $this->onlyPost();
98 98
 
99
-        $user = (object)$this->request->getDataFull();
99
+        $user = (object) $this->request->getDataFull();
100 100
         $redirectUrl = "/admin";
101 101
 
102 102
         if ($user->userId !== $this->session->get("userId") || isset($user->userRoleSelector) || isset($user->locked_out)) {
103 103
             //an admin is trying to update a user or form tampered with
104 104
             $this->onlyAdmin();
105
-            $redirectUrl = "/admin/home/view-user/" . $user->userId;
106
-        } else {
105
+            $redirectUrl = "/admin/home/view-user/".$user->userId;
106
+        }else {
107 107
             //set the role to the original state for update
108 108
             $beforeUser = $this->userModel->getUserDetailsById($user->userId);
109 109
             $user->userRoleSelector = $beforeUser->roles_idroles;
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
         $error = false;
118 118
         $registerErrors = new \stdClass();
119 119
 
120
-        if($userId == 1 && $user->userLockedOut == 1)
120
+        if ($userId == 1 && $user->userLockedOut == 1)
121 121
         {
122 122
             $error = true;
123 123
             $this->alertBox->setAlert("Original admin may not be deactivated", "error");
124 124
         }
125 125
 
126
-        if($userId == 1 && $user->userRoleSelector != 2)
126
+        if ($userId == 1 && $user->userRoleSelector != 2)
127 127
         {
128 128
             $error = true;
129 129
             $this->alertBox->setAlert("Original admin must stay admin", "error");
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
             throw new \Exception("Error in passed ID");
205 205
         }
206 206
 
207
-        if($userId === 1)
207
+        if ($userId === 1)
208 208
         {
209 209
             $this->alertBox->setAlert('Original Admin can not be deleted', "error");
210 210
             $this->response->redirect("/admin/home/list-users");
Please login to merge, or discard this patch.
App/Controllers/Ajax/User.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use Core\JsonException;
9 9
 use Core\Traits\StringFunctions;
10 10
 
11
-class User  extends AjaxController{
11
+class User  extends AjaxController {
12 12
 
13 13
     use StringFunctions;
14 14
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         //the router needs a parameter with get functions else throsw a wobbly
26 26
         //we pass a get variable and call the /controller/function/get?bla
27 27
         //for better use and security, we must pass "get" as the parameter
28
-        if(!$this->startsWith(strtolower($get),"get"))
28
+        if (!$this->startsWith(strtolower($get), "get"))
29 29
         {
30 30
             throw new JsonException("invalid call");
31 31
         }
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
     {
47 47
         $this->onlyAdmin();
48 48
         $this->onlyPost();
49
-        $state = (bool)($this->request->getData("state") === 'true');
50
-        $userId = (int)$this->request->getData("userId");
49
+        $state = (bool) ($this->request->getData("state") === 'true');
50
+        $userId = (int) $this->request->getData("userId");
51 51
 
52 52
         $result = array();
53 53
         $result["success"] = false;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $result["userId"] = $userId;
56 56
 
57 57
         // we can not update the Original Admin activation state
58
-        if($userId !== 1)
58
+        if ($userId !== 1)
59 59
         {
60 60
             $result["success"] = $this->userModel->activateUser(!$state, $userId);
61 61
             $result["state"] = !$state;
Please login to merge, or discard this patch.
App/Modules/SendMail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use Swift_Message;
9 9
 use Swift_SmtpTransport;
10 10
 
11
-class SendMail extends Module{
11
+class SendMail extends Module {
12 12
 
13 13
     private $siteConfig;
14 14
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
         // Create the Transport for mail sending
26 26
         //$config = $this->siteConfig->getSiteConfig();
27
-        $this->transport = (new Swift_SmtpTransport($this->siteConfig["SMTP_server"], (int)$this->siteConfig["SMTP_port"]))
27
+        $this->transport = (new Swift_SmtpTransport($this->siteConfig["SMTP_server"], (int) $this->siteConfig["SMTP_port"]))
28 28
             ->setUsername($this->siteConfig["SMTP_user"])
29 29
             ->setPassword($this->siteConfig["SMTP_pass"])
30 30
         ;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $message = "<h1>Message from <a href='".$this->container->getRequest()->getBaseUrl()."'>".$this->siteConfig["site_name"]."</a></h1>";
70 70
         $message .= "<p>You have asked to reset your password, please click <a href=\"".$url."\">Here</a> to define a new password</p>";
71 71
 
72
-        $this->send($to, "Define New Password", $message );
72
+        $this->send($to, "Define New Password", $message);
73 73
 
74 74
     }
75 75
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         $message .= "<p>You have sucsessfuly created an account, now all you need to do is <a href=\"".$url."\">Create your new password</a></p>";
90 90
         $message .= "<p>Have fun</p>";
91 91
 
92
-        $this->send($to, "Define Password at ".$this->siteConfig["site_name"], $message );
92
+        $this->send($to, "Define Password at ".$this->siteConfig["site_name"], $message);
93 93
 
94 94
     }
95 95
 }
96 96
\ No newline at end of file
Please login to merge, or discard this patch.