Passed
Push — master ( 2d2cc5...c6a2fc )
by Corey
03:13
created
site/models/SignupForm.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
    */
96 96
   public function signup() {
97 97
     $user = $this->user->findByEmail($this->email);
98
-    if(!$user) {
98
+    if (!$user) {
99 99
       // this is a brand new user
100 100
       $this->user = $this->setFields($this->user);
101 101
       $this->user->save();
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
        * this is a user that for whatever reason is trying to sign up again
110 110
        * with the same email address.
111 111
        */
112
-      if(!$user->isTokenConfirmed()) {
112
+      if (!$user->isTokenConfirmed()) {
113 113
         /*
114 114
          * they've never verified their account. We don't care if their
115 115
          * verification token is current or expired. We're resetting their
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
       $user->generateAuthKey();
137 137
       $user->generateVerifyEmailToken();
138 138
 
139
-      if($this->send_email) {
139
+      if ($this->send_email) {
140 140
         $user->email_threshold = $this->email_threshold;
141 141
         $user->partner_email1  = $this->partner_email1;
142 142
         $user->partner_email2  = $this->partner_email2;
Please login to merge, or discard this patch.
site/models/EditProfileForm.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
       ['email', 'filter', 'filter' => 'trim'],
43 43
       ['email', 'filter', 'filter' => 'strtolower'],
44 44
       ['email', 'email'],
45
-      ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.', 'filter' => "id <> ".Yii::$app->user->id],
45
+      ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.', 'filter' => "id <> " . Yii::$app->user->id],
46 46
 
47 47
 
48 48
       ['timezone', 'string', 'min' => 2, 'max' => 255],
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
       $graph = Yii::$container
89 89
         ->get('common\components\Graph', [$this->user]);
90 90
 
91
-      if($this->email)
91
+      if ($this->email)
92 92
         $user->email = $this->email;
93
-      if($this->timezone)
93
+      if ($this->timezone)
94 94
         $user->timezone = $this->timezone;
95
-      if($this->expose_graph) {
95
+      if ($this->expose_graph) {
96 96
         $user->expose_graph = true;
97 97
 
98 98
         // generate scores graph image
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         // if they haven't done a check-in in the last month this
101 101
         // will explode because $scores_last_month is an empty
102 102
         // array
103
-        if($scores_last_month) {
103
+        if ($scores_last_month) {
104 104
           $graph->create($scores_last_month, true);
105 105
         }
106 106
       } else {
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         // remove scores graph image
109 109
         $graph->destroy();
110 110
       }
111
-      if($this->send_email) {
111
+      if ($this->send_email) {
112 112
         $user->email_threshold = $this->email_threshold;
113 113
         $user->partner_email1  = $this->partner_email1;
114 114
         $user->partner_email2  = $this->partner_email2;
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -88,10 +88,12 @@
 block discarded – undo
88 88
       $graph = Yii::$container
89 89
         ->get('common\components\Graph', [$this->user]);
90 90
 
91
-      if($this->email)
92
-        $user->email = $this->email;
93
-      if($this->timezone)
94
-        $user->timezone = $this->timezone;
91
+      if($this->email) {
92
+              $user->email = $this->email;
93
+      }
94
+      if($this->timezone) {
95
+              $user->timezone = $this->timezone;
96
+      }
95 97
       if($this->expose_graph) {
96 98
         $user->expose_graph = true;
97 99
 
Please login to merge, or discard this patch.
site/models/QuestionForm.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -157,11 +157,11 @@
 block discarded – undo
157 157
       foreach($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) {
158 158
         $question_id = \common\models\Question::$TYPES[$answer_letter];
159 159
         array_push($answers, [
160
-                               'behavior_id'    => $user_bhvr->behavior_id,
161
-                               'user_bhvr_id' => $user_bhvr->id,
162
-                               'question_id'  => $question_id,
163
-                               'answer'       => $answer,
164
-                             ]);
160
+                                'behavior_id'    => $user_bhvr->behavior_id,
161
+                                'user_bhvr_id' => $user_bhvr->id,
162
+                                'question_id'  => $question_id,
163
+                                'answer'       => $answer,
164
+                              ]);
165 165
       }
166 166
     }
167 167
     return $answers;
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         'whenClient' => "function(attribute, value) { return false; }", // lame, but acceptable
84 84
         "message" => "You must select a behavior your responses apply to."],
85 85
 
86
-      [['answer_1a','answer_1b','answer_1c','answer_2a','answer_2b','answer_2c','answer_3a','answer_3b','answer_3c','answer_4a','answer_4b','answer_4c','answer_5a', 'answer_5b','answer_5c','answer_6a', 'answer_6b','answer_6c','answer_7a','answer_7b','answer_7c'], 'safe']
86
+      [['answer_1a', 'answer_1b', 'answer_1c', 'answer_2a', 'answer_2b', 'answer_2c', 'answer_3a', 'answer_3b', 'answer_3c', 'answer_4a', 'answer_4b', 'answer_4c', 'answer_5a', 'answer_5b', 'answer_5c', 'answer_6a', 'answer_6b', 'answer_6c', 'answer_7a', 'answer_7b', 'answer_7c'], 'safe']
87 87
     ];
88 88
   }
89 89
 
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 
102 102
   public function getBhvrValidator() {
103 103
     return function($model, $attr) {
104
-      $attrNum = $attr[strlen($attr)-1];
105
-      foreach(['a', 'b', 'c'] as $l) {
104
+      $attrNum = $attr[strlen($attr) - 1];
105
+      foreach (['a', 'b', 'c'] as $l) {
106 106
         $attr = "answer_{$attrNum}{$l}";
107
-        if($model->$attr) return true;
107
+        if ($model->$attr) return true;
108 108
       }
109 109
       return false;
110 110
     };
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
   public function getPrefixProps($prefix) {
136 136
     return array_filter(get_object_vars($this), function($v, $k) use($prefix) {
137
-      if(strpos($k, $prefix) === 0 && strlen($v)) {
137
+      if (strpos($k, $prefix) === 0 && strlen($v)) {
138 138
         return true;
139 139
       }
140 140
     }, ARRAY_FILTER_USE_BOTH);
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
   public function getAnswers($bhvrs) {
153 153
     $answers = [];
154 154
     $user_bhvrs = array_combine($this->getUserBehaviorProps(), $bhvrs);
155
-    foreach($user_bhvrs as $property => $user_bhvr) {
155
+    foreach ($user_bhvrs as $property => $user_bhvr) {
156 156
       $behavior_id = intval(substr($property, -1, 1));
157
-      foreach($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) {
157
+      foreach ($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) {
158 158
         $question_id = \common\models\Question::$TYPES[$answer_letter];
159 159
         array_push($answers, [
160 160
                                'behavior_id'    => $user_bhvr->behavior_id,
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
   public function saveAnswers($bhvrs) {
171 171
     $result = true;
172
-    foreach($this->getAnswers($bhvrs) as $answer) {
172
+    foreach ($this->getAnswers($bhvrs) as $answer) {
173 173
       $model = new \common\models\Question;
174 174
       $model->user_id = Yii::$app->user->id;
175 175
       $model->behavior_id = $answer['behavior_id'];
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
       $model->date = new Expression("now()::timestamp");
178 178
       $model->question = $answer['question_id'];
179 179
       $model->answer = $answer['answer'];
180
-      if(!$model->save()) {
180
+      if (!$model->save()) {
181 181
         $result = false;
182 182
       }
183 183
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,9 @@
 block discarded – undo
104 104
       $attrNum = $attr[strlen($attr)-1];
105 105
       foreach(['a', 'b', 'c'] as $l) {
106 106
         $attr = "answer_{$attrNum}{$l}";
107
-        if($model->$attr) return true;
107
+        if($model->$attr) {
108
+          return true;
109
+        }
108 110
       }
109 111
       return false;
110 112
     };
Please login to merge, or discard this patch.
site/controllers/ProfileController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
     if ($editProfileForm->load(Yii::$app->request->post())) {
69 69
       $saved_user = $editProfileForm->saveProfile();
70
-      if($saved_user) {
70
+      if ($saved_user) {
71 71
         Yii::$app->getSession()->setFlash('success', 'New profile data saved!');
72 72
       }
73 73
     }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     $model = Yii::$container->get('\site\models\DeleteAccountForm', [Yii::$app->user->identity]);
86 86
 
87 87
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
88
-      if($model->deleteAccount()) {
88
+      if ($model->deleteAccount()) {
89 89
         $this->redirect(['site/index']);
90 90
       } else {
91 91
         Yii::$app->getSession()->setFlash('error', 'Wrong password!');
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     $model = Yii::$container->get('\site\models\ChangePasswordForm', [Yii::$app->user->identity]);
101 101
 
102 102
     if ($model->load(Yii::$app->request->post())) {
103
-      if($model->validate() && $model->changePassword()) {
103
+      if ($model->validate() && $model->changePassword()) {
104 104
         Yii::$app->getSession()->setFlash('success', 'Password successfully changed');
105 105
       } else {
106 106
         Yii::$app->getSession()->setFlash('error', 'Wrong password!');
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
   public function actionExport()
114 114
   {
115 115
     header("Content-Type: text/csv");
116
-    header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv");
116
+    header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv");
117 117
 
118 118
     $reader = Yii::$app->user->identity->getExportData();
119 119
     $fp = fopen('php://output', 'w');
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
     fputcsv($fp, $header);
131 131
     $user_behavior = Yii::$container->get('common\interfaces\UserBehaviorInterface');
132
-    while($row = $reader->read()) {
132
+    while ($row = $reader->read()) {
133 133
       $row = $user_behavior::decorateWithCategory([$row]);
134 134
       $row = Yii::$app->user->identity->cleanExportData($row);
135 135
       fputcsv($fp, $row[0]);
Please login to merge, or discard this patch.
site/controllers/SiteController.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
   public function actionIndex()
72 72
   {
73 73
     $time = Yii::$container->get('common\interfaces\TimeInterface'); 
74
-    $key = "index_blog_".$time->getLocalDate('UTC');
74
+    $key = "index_blog_" . $time->getLocalDate('UTC');
75 75
     $posts = Yii::$app->cache->get($key);
76
-    if($posts === false) {
76
+    if ($posts === false) {
77 77
       $posts = \Yii::$app->getModule('blog')
78 78
                             ->fetch()
79 79
                             ->parse()
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
   {
107 107
     $model = new ContactForm();
108 108
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
109
-      if($model->sendEmail(Yii::$app->params['adminEmail'])) {
109
+      if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
110 110
         Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
111 111
       } else {
112 112
         Yii::$app->session->setFlash('error', 'There was an error sending email.');
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
   public function actionSignup()
139 139
   {
140 140
     $model = Yii::$container->get('\site\models\SignupForm');
141
-    if($model->load(Yii::$app->request->post()) && $model->validate()) {
141
+    if ($model->load(Yii::$app->request->post()) && $model->validate()) {
142 142
       $model->signup();
143 143
       Yii::$app->getSession()->setFlash('success', 'We have sent a verification email to the email address you provided. Please check your inbox and follow the instructions to verify your account.');
144
-      return $this->redirect('/',302);
144
+      return $this->redirect('/', 302);
145 145
     }
146 146
 
147 147
     return $this->render('signup', [
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
   public function actionRequestPasswordReset()
153 153
   {
154 154
     $model = Yii::$container->get('\site\models\PasswordResetRequestForm');
155
-    if($model->load(Yii::$app->request->post()) && $model->validate()) {
156
-      if(!$model->sendEmail()) {
155
+    if ($model->load(Yii::$app->request->post()) && $model->validate()) {
156
+      if (!$model->sendEmail()) {
157 157
         $ip = Yii::$app->getRequest()->getUserIP() ?: "UNKNOWN";
158
-        Yii::warning("$ip has tried to reset the password for ".$model->email);
158
+        Yii::warning("$ip has tried to reset the password for " . $model->email);
159 159
       }
160 160
 
161 161
       Yii::$app->getSession()->setFlash('success', 'If there is an account with the submitted email address you will receive further instructions in your email inbox.');
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
       throw new BadRequestHttpException("Wrong or expired email verification token. If you aren't sure why this error occurs perhaps you've already verified your account. Please try logging in.");
199 199
     }
200 200
 
201
-    if($user->isTokenConfirmed($user->verify_email_token)) {
201
+    if ($user->isTokenConfirmed($user->verify_email_token)) {
202 202
       Yii::$app->getSession()->setFlash('success', 'Your account has already been verified. Please log in.');
203
-      return $this->redirect('/login',302);
203
+      return $this->redirect('/login', 302);
204 204
     } else if (Yii::$app->getUser()->login($user)) {
205 205
       $user->confirmVerifyEmailToken();
206 206
       $user->save();
207 207
       Yii::$app->getSession()->setFlash('success', 'Your account has been verified. Please continue with your check-in.');
208
-      return $this->redirect('/welcome',302);
208
+      return $this->redirect('/welcome', 302);
209 209
     }
210 210
   }
211 211
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
   public function actionExport()
223 223
   {
224 224
     header("Content-Type: text/csv");
225
-    header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv");
225
+    header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv");
226 226
 
227 227
     $reader = Yii::$app->user->identity->getExportData();
228 228
     $fp = fopen('php://output', 'w');
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
     fputcsv($fp, $header);
240 240
     $user_behavior = Yii::$container->get('common\interfaces\UserBehaviorInterface');
241
-    while($row = $reader->read()) {
241
+    while ($row = $reader->read()) {
242 242
       $row = $user_behavior::decorateWithCategory([$row]);
243 243
       $row = Yii::$app->user->identity->cleanExportData($row);
244 244
       fputcsv($fp, $row[0]);
Please login to merge, or discard this patch.
site/web/router.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@
 block discarded – undo
7 7
 set_include_path(get_include_path().':'.__DIR__);
8 8
 if(file_exists($root.$path))
9 9
 {
10
-	if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
11
-		$path = rtrim($path,'/').'/index.php';
12
-	if(strpos($path,'.php') === false) return false;
13
-	else {
14
-		chdir(dirname($root.$path));
15
-		require_once $root.$path;
16
-	}
10
+  if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
11
+    $path = rtrim($path,'/').'/index.php';
12
+  if(strpos($path,'.php') === false) return false;
13
+  else {
14
+    chdir(dirname($root.$path));
15
+    require_once $root.$path;
16
+  }
17 17
 }else include_once 'index.php';
18 18
 ?>
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@
 block discarded – undo
3 3
 header("Access-Control-Allow-Origin: *");
4 4
 $root = $_SERVER['DOCUMENT_ROOT'];
5 5
 chdir($root);
6
-$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
7
-set_include_path(get_include_path().':'.__DIR__);
8
-if(file_exists($root.$path))
6
+$path = '/' . ltrim(parse_url($_SERVER['REQUEST_URI'])['path'], '/');
7
+set_include_path(get_include_path() . ':' . __DIR__);
8
+if (file_exists($root . $path))
9 9
 {
10
-	if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
11
-		$path = rtrim($path,'/').'/index.php';
12
-	if(strpos($path,'.php') === false) return false;
10
+	if (is_dir($root . $path) && substr($path, strlen($path) - 1, 1) !== '/')
11
+		$path = rtrim($path, '/') . '/index.php';
12
+	if (strpos($path, '.php') === false) return false;
13 13
 	else {
14
-		chdir(dirname($root.$path));
15
-		require_once $root.$path;
14
+		chdir(dirname($root . $path));
15
+		require_once $root . $path;
16 16
 	}
17
-}else include_once 'index.php';
17
+} else include_once 'index.php';
18 18
 ?>
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,12 +7,16 @@
 block discarded – undo
7 7
 set_include_path(get_include_path().':'.__DIR__);
8 8
 if(file_exists($root.$path))
9 9
 {
10
-	if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
11
-		$path = rtrim($path,'/').'/index.php';
12
-	if(strpos($path,'.php') === false) return false;
13
-	else {
10
+	if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') {
11
+			$path = rtrim($path,'/').'/index.php';
12
+	}
13
+	if(strpos($path,'.php') === false) {
14
+	  return false;
15
+	} else {
14 16
 		chdir(dirname($root.$path));
15 17
 		require_once $root.$path;
16 18
 	}
17
-}else include_once 'index.php';
19
+} else {
20
+  include_once 'index.php';
21
+}
18 22
 ?>
Please login to merge, or discard this patch.
site/tests/_support/UnitTester.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 {
21 21
     use _generated\UnitTesterActions;
22 22
 
23
-   /**
24
-    * Define custom actions here
25
-    */
23
+    /**
24
+     * Define custom actions here
25
+     */
26 26
 }
Please login to merge, or discard this patch.
site/views/site/contact.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
         <?= $form->field($model, 'subject') ?>
58 58
         <?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
59 59
 
60
-        <?php if(Yii::$app->user->isGuest) {
60
+        <?php if (Yii::$app->user->isGuest) {
61 61
           // only show captcha if user is not logged in
62 62
           print $form->field($model, 'verifyCode')->widget(Captcha::class, [
63 63
             'template' => '<div class="row"><div class="col-md-3">{image}</div><div class="col-md-6">{input}</div></div>',
Please login to merge, or discard this patch.
common/models/Category.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@
 block discarded – undo
15 15
 
16 16
   // a weight of 0 means selections in that category do not increase the score
17 17
   public static $categories = [
18
-    [ "id" => 1, "weight" => 0,  "name" => "Restoration"],
19
-    [ "id" => 2, "weight" => 1,  "name" => "Forgetting Priorities"],
20
-    [ "id" => 3, "weight" => 2,  "name" => "Anxiety"],
21
-    [ "id" => 4, "weight" => 4,  "name" => "Speeding Up"],
22
-    [ "id" => 5, "weight" => 6,  "name" => "Ticked Off"],
23
-    [ "id" => 6, "weight" => 8,  "name" => "Exhausted"],
24
-    [ "id" => 7, "weight" => 10, "name" => "Relapse/Moral Failure"],
18
+    ["id" => 1, "weight" => 0, "name" => "Restoration"],
19
+    ["id" => 2, "weight" => 1, "name" => "Forgetting Priorities"],
20
+    ["id" => 3, "weight" => 2, "name" => "Anxiety"],
21
+    ["id" => 4, "weight" => 4, "name" => "Speeding Up"],
22
+    ["id" => 5, "weight" => 6, "name" => "Ticked Off"],
23
+    ["id" => 6, "weight" => 8, "name" => "Exhausted"],
24
+    ["id" => 7, "weight" => 10, "name" => "Relapse/Moral Failure"],
25 25
   ];
26 26
 
27 27
   public static $colors = [
Please login to merge, or discard this patch.