Completed
Pull Request — master (#178)
by Corey
03:04
created
site/tests/unit/models/SignupFormTest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
     $this->container = new \yii\di\Container;
33 33
     $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser');
34 34
     $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior');
35
-    $this->container->set('common\interfaces\TimeInterface', function () {
35
+    $this->container->set('common\interfaces\TimeInterface', function() {
36 36
       return new \common\components\Time('America/Los_Angeles');
37 37
     });
38 38
 
39 39
     // instantiate mock objects
40 40
     $user_behavior = $this->container->get(\common\interfaces\UserBehaviorInterface::class);
41
-    $time        = $this->container->get(\common\interfaces\TimeInterface::class);
41
+    $time = $this->container->get(\common\interfaces\TimeInterface::class);
42 42
 
43 43
     $question = $this->getMockBuilder(\common\models\Question::class)
44 44
       ->setMethods(['save', 'attributes'])
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
     // set up a side effect to occur when the user's save() function is called
109 109
     $saved = false;
110
-    $this->user->method('save')->will($this->returnCallback(function($runValidation=true, $attributeNames=null) use(&$saved) {
110
+    $this->user->method('save')->will($this->returnCallback(function($runValidation = true, $attributeNames = null) use(&$saved) {
111 111
       $saved = true;
112 112
       return $this->user;
113 113
     }));
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
  
134 134
   public function testSignupExistingConfirmedUser() {
135 135
     $saved = false;
136
-    $this->existing_user->method('save')->will($this->returnCallback(function($runValidation=true, $attributeNames=null) use(&$saved) {
136
+    $this->existing_user->method('save')->will($this->returnCallback(function($runValidation = true, $attributeNames = null) use(&$saved) {
137 137
       $saved = true;
138 138
       return $this->existing_user;
139 139
     }));
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
   public function testSignupExistingUnconfirmedUser() {
154 154
     $saved = false;
155
-    $this->existing_user->method('save')->will($this->returnCallback(function($runValidation=true, $attributeNames=null) use(&$saved) {
155
+    $this->existing_user->method('save')->will($this->returnCallback(function($runValidation = true, $attributeNames = null) use(&$saved) {
156 156
       $saved = true;
157 157
       return $this->existing_user;
158 158
     }));
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 
184 184
     $result = $form->setFields($this->user);
185 185
     $this->specify('populate should set the values of the user model from the form', function() use ($result) {
186
-      foreach($this->whitelist as $attr) {
186
+      foreach ($this->whitelist as $attr) {
187 187
         $this->assertEquals($this->vals[$attr], $result->$attr);
188 188
       }
189 189
     });
190 190
   }
191 191
 
192 192
   private function setAttrs($form, Array $vals) {
193
-    foreach($vals as $key => $val) {
193
+    foreach ($vals as $key => $val) {
194 194
       $form->$key = $val;
195 195
     }
196 196
     return $form;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
   }
212 212
 
213 213
   private function getForm($user = null) {
214
-    if(is_null($user)) $user = $this->user;
214
+    if (is_null($user)) $user = $this->user;
215 215
     $form = $this->container->get('\site\models\SignupForm', [$user]);
216 216
     $form->attributes = $this->vals; // massive assignment
217 217
     return $form;
Please login to merge, or discard this patch.
common/mail/checkinReport.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
                                                 <th style="Margin:0;color:#0a0a0a;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
126 126
 
127 127
 <?php
128
-if($questions) {
129
-  foreach($questions as $behavior_id => $behavior_questions) {
128
+if ($questions) {
129
+  foreach ($questions as $behavior_id => $behavior_questions) {
130 130
 ?>
131 131
 
132 132
                                                    <h4 style="Margin:0;Margin-bottom:10px;color:#37b98f;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:24px;font-weight:400;line-height:1.3;margin:0;margin-bottom:5px;padding:0 8px;text-align:left;word-wrap:normal"> <?= Html::encode($behavior_questions['question']['behavior_name']) ?> </h4>
133 133
 
134 134
 <?php
135
-    foreach($behavior_questions['answers'] as $key => $question) {  ?>
135
+    foreach ($behavior_questions['answers'] as $key => $question) {  ?>
136 136
       <p style="Margin:0;Margin-bottom:10px;color:#0a0a0a;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0 8px 4px 8px;text-align:left"><strong><?= Html::encode($question['title']) ?></strong> <?= Html::encode($question['answer']) ?></p>
137 137
 <?php
138 138
     }
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
                                                 <th style="Margin:0;color:#0a0a0a;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
190 190
 
191 191
 <?php
192
-if($user_behaviors) {
193
-  foreach($user_behaviors as $cat_key => $behaviors) { ?>
192
+if ($user_behaviors) {
193
+  foreach ($user_behaviors as $cat_key => $behaviors) { ?>
194 194
         <p style="Margin:0;Margin-bottom:10px;color:#0a0a0a;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0 8px 4px 8px;text-align:left">
195 195
           <strong style="color:#37b98f"><?= Html::encode($categories[$cat_key]) ?></strong>
196 196
 <?php
197
-    foreach($behaviors as $behavior) { ?>
197
+    foreach ($behaviors as $behavior) { ?>
198 198
         <br><?= Html::encode($behavior['name']) ?>
199 199
 <?php
200 200
     }
Please login to merge, or discard this patch.
common/tests/unit/models/UserTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     $this->container = new \yii\di\Container;
89 89
     $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser');
90 90
     $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior');
91
-    $this->container->set('common\interfaces\TimeInterface', function () {
91
+    $this->container->set('common\interfaces\TimeInterface', function() {
92 92
       return new \common\components\Time('America/Los_Angeles');
93 93
     });
94 94
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
   }
135 135
 
136 136
   public function testIsTokenCurrent() {
137
-    $this->specify('isTokenCurrent should function correctly', function () {
137
+    $this->specify('isTokenCurrent should function correctly', function() {
138 138
       $good_token = \Yii::$app
139 139
                       ->getSecurity()
140 140
                       ->generateRandomString() . '_' . time();
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
   public function testConfirmVerifyEmailToken() {
169 169
     $this->user->verify_email_token = 'hello_world';
170 170
     $this->user->confirmVerifyEmailToken();
171
-    expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world'.$this->user::CONFIRMED_STRING));
171
+    expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world' . $this->user::CONFIRMED_STRING));
172 172
   }
173 173
 
174 174
   public function testIsVerified() {
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
       ->disableOriginalConstructor()
263 263
       ->setMethods(['save', 'attributes', 'getCheckinBreakdown'])
264 264
       ->getMock();
265
-    $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php');
265
+    $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php');
266 266
     $user_behavior->method('getCheckinBreakdown')->willReturn($expected);
267 267
 
268 268
     $user = $this->getMockBuilder(User::class)
Please login to merge, or discard this patch.
site/controllers/ProfileController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
             'allow'   => true,
28 28
             'roles'   => ['@'],
29 29
           ], [
30
-            'actions' => [ 'change-email', ],
30
+            'actions' => ['change-email', ],
31 31
             'allow'   => true,
32 32
           ],
33 33
         ],
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
     if ($editProfileForm->load(Yii::$app->request->post())) {
60 60
       $saved_user = $editProfileForm->saveProfile();
61
-      if($saved_user) {
61
+      if ($saved_user) {
62 62
         Yii::$app->session->setFlash('success', 'New profile data saved!');
63 63
       }
64 64
     }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     $model = Yii::$container->get(\site\models\DeleteAccountForm::class, [Yii::$app->user->identity]);
79 79
 
80 80
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
81
-      if($model->deleteAccount()) {
81
+      if ($model->deleteAccount()) {
82 82
         $this->redirect(['site/index']);
83 83
       } else {
84 84
         Yii::$app->session->setFlash('error', 'Wrong password!');
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     $model = Yii::$container->get(\site\models\ChangePasswordForm::class, [Yii::$app->user->identity]);
93 93
 
94 94
     if ($model->load(Yii::$app->request->post())) {
95
-      if($model->validate() && $model->changePassword()) {
95
+      if ($model->validate() && $model->changePassword()) {
96 96
         Yii::$app->session->setFlash('success', 'Password successfully changed');
97 97
       } else {
98 98
         Yii::$app->session->setFlash('error', 'Wrong password!');
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
   public function actionChangeEmail(string $token) {
117 117
     $user = Yii::$container->get(\common\interfaces\UserInterface::class)->findByChangeEmailToken($token);
118 118
 
119
-    if($user) {
119
+    if ($user) {
120 120
       $validator = new \yii\validators\EmailValidator();
121
-      if($validator->validate($user->desired_email, $error)) {
121
+      if ($validator->validate($user->desired_email, $error)) {
122 122
         $user->removeChangeEmailToken();
123 123
         $user->email = $user->desired_email;
124 124
         $user->desired_email = null;
125 125
         $user->save();
126
-        if(!Yii::$app->user->isGuest) {
126
+        if (!Yii::$app->user->isGuest) {
127 127
           Yii::$app->user->logout();
128 128
           Yii::$app->session->setFlash('success', 'Your email address was successfully changed. For security, we\'ve logged you out.');
129 129
         } else {
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
   public function actionExport() {
145 145
     header("Content-Type: text/csv");
146
-    header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv");
146
+    header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv");
147 147
 
148 148
     $reader = Yii::$app->user->identity->getExportData();
149 149
     $fp = fopen('php://output', 'w');
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
     fputcsv($fp, $header);
161 161
     $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class);
162
-    while($row = $reader->read()) {
162
+    while ($row = $reader->read()) {
163 163
       $row = $user_behavior::decorate([$row]);
164 164
       $row = Yii::$app->user->identity->cleanExportRow($row[0]);
165 165
       fputcsv($fp, $row);
Please login to merge, or discard this patch.
common/tests/unit/models/QuestionTest.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -157,15 +157,15 @@
 block discarded – undo
157 157
 
158 158
   public function setUp() {
159 159
     $this->question = $this->getMockBuilder('\common\models\Question')
160
-         ->setMethods(['save', 'attributes'])
161
-         ->getMock();
160
+          ->setMethods(['save', 'attributes'])
161
+          ->getMock();
162 162
   }
163 163
 
164 164
   public function testParseQuestionData() {
165 165
     $questions = array_map(function ($d) {
166 166
       $q = $this->getMockBuilder('\common\models\Question')
167
-         ->setMethods(['save', 'attributes'])
168
-         ->getMock();
167
+          ->setMethods(['save', 'attributes'])
168
+          ->getMock();
169 169
       $q->method('save')->willReturn(true);
170 170
       $q->method('attributes')
171 171
         ->willReturn([
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
   }
163 163
 
164 164
   public function testParseQuestionData() {
165
-    $questions = array_map(function ($d) {
165
+    $questions = array_map(function($d) {
166 166
       $q = $this->getMockBuilder('\common\models\Question')
167 167
          ->setMethods(['save', 'attributes'])
168 168
          ->getMock();
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
           'date',
180 180
           'userBehavior',
181 181
         ]);
182
-      foreach($d as $k => $v) {
183
-        if($k === 'behavior_id' && $v === null) {
182
+      foreach ($d as $k => $v) {
183
+        if ($k === 'behavior_id' && $v === null) {
184 184
           $ub = new \StdClass();
185 185
           $ub->custom_behavior = 'some_custom_behavior';
186 186
           $q->userBehavior = $ub;
Please login to merge, or discard this patch.
common/models/UserBehavior.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
       ->groupBy('date, user_id')
93 93
       ->having('user_id = :user_id');
94 94
     $temp_dates = $query->all();
95
-    foreach($temp_dates as $temp_date) {
95
+    foreach ($temp_dates as $temp_date) {
96 96
       $past_checkin_dates[] = $this->time->convertUTCToLocal($temp_date['date']);
97 97
     }
98 98
 
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 
122 122
   public function getCheckinBreakdown(int $period = 30) {
123 123
     $datetimes = $this->time->getDateTimesInPeriod($period);
124
-    $key = "checkins_".Yii::$app->user->id."_{$period}_".$this->time->getLocalDate();
124
+    $key = "checkins_" . Yii::$app->user->id . "_{$period}_" . $this->time->getLocalDate();
125 125
     $checkins = Yii::$app->cache->get($key);
126 126
 
127
-    if($checkins === false) {
127
+    if ($checkins === false) {
128 128
       $checkins = [];
129
-      foreach($datetimes as $datetime) {
129
+      foreach ($datetimes as $datetime) {
130 130
         $behaviors = self::decorate($this->getBehaviorsWithCounts($datetime));
131 131
         $checkins[$datetime->format('Y-m-d')] = $this->getBehaviorsByCategory($behaviors);
132 132
       }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
   public function getBehaviorsByCategory(array $decorated_behaviors) {
153 153
     $arr = array_reduce($decorated_behaviors, function($acc, $row) {
154 154
       $cat_id = $row['category_id'];
155
-      if(array_key_exists($cat_id, $acc)) {
155
+      if (array_key_exists($cat_id, $acc)) {
156 156
         $acc[$cat_id]['count'] += $row['count'];
157 157
       } else {
158 158
         $acc[$cat_id] = [
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
       ->having('user_id = :user_id')
185 185
       ->orderBy('count DESC');
186 186
 
187
-    if($limit instanceof \DateTime) {
187
+    if ($limit instanceof \DateTime) {
188 188
       list($start, $end) = $this->time->getUTCBookends($limit->format('Y-m-d'));
189 189
       $query->params += [':start_date' => $start, ':end_date' => $end];
190 190
       $query->where('user_id=:user_id AND date > :start_date AND date <= :end_date');
191
-    } else if(is_int($limit)) {
191
+    } else if (is_int($limit)) {
192 192
       $query->limit($limit);
193 193
     }
194 194
     return $query->all();
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
    * @return array
203 203
    */
204 204
   public function getByDate(int $user_id, $local_date = null) {
205
-    if(is_null($local_date)) $local_date = $this->time->getLocalDate();
205
+    if (is_null($local_date)) $local_date = $this->time->getLocalDate();
206 206
 
207 207
     $behaviors = $this->getBehaviorData($user_id, $local_date);
208 208
     $behaviors = self::decorate($behaviors);
@@ -215,13 +215,13 @@  discard block
 block discarded – undo
215 215
    * @return an array of decorated UserBehaviors, each with an added Category and Behavior
216 216
    */
217 217
   public static function decorate(array $uo) {
218
-    foreach($uo as &$o) {
218
+    foreach ($uo as &$o) {
219 219
       $behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id']);
220 220
       $category = \common\models\Category::getCategory('id', $o['category_id']);
221
-      if($behavior) {
221
+      if ($behavior) {
222 222
         $o['behavior'] = $behavior;
223 223
       }
224
-      if($category) {
224
+      if ($category) {
225 225
         $o['category'] = $category;
226 226
       }
227 227
     }
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 
248 248
   // TODO: this should probably be a private method...but unit testing is hard
249 249
   public function parseBehaviorData($behaviors) {
250
-    if(!$behaviors) return [];
250
+    if (!$behaviors) return [];
251 251
 
252 252
     $bhvrs_by_cat = [];
253
-    foreach($behaviors as $behavior) {
253
+    foreach ($behaviors as $behavior) {
254 254
       $indx = $behavior['category_id'];
255 255
 
256 256
       $bname = AH::getValue($behavior, 'behavior.name', AH::getValue($behavior, 'custom_behavior'));
Please login to merge, or discard this patch.
site/models/QuestionForm.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
   public function __construct(QuestionInterface $question,
54 54
                               $config = []) {
55
-    $this->question    = $question;
55
+    $this->question = $question;
56 56
     parent::__construct($config);
57 57
   }
58 58
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         'whenClient' => "function(attribute, value) { return false; }", // lame, but acceptable
71 71
         "message" => "You must select a behavior your responses apply to."],
72 72
 
73
-      [['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']
73
+      [['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']
74 74
     ];
75 75
   }
76 76
 
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 
89 89
   public function getBhvrValidator() {
90 90
     return function($model, $attr) {
91
-      $attrNum = $attr[strlen($attr)-1];
92
-      foreach(['a', 'b', 'c'] as $l) {
91
+      $attrNum = $attr[strlen($attr) - 1];
92
+      foreach (['a', 'b', 'c'] as $l) {
93 93
         $attr = "answer_{$attrNum}{$l}";
94
-        if($model->$attr) return true;
94
+        if ($model->$attr) return true;
95 95
       }
96 96
       return false;
97 97
     };
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
   public function getPrefixProps($prefix) {
124 124
     return array_filter(get_object_vars($this), function($v, $k) use($prefix) {
125
-      if(strpos($k, $prefix) === 0 && strlen($v)) {
125
+      if (strpos($k, $prefix) === 0 && strlen($v)) {
126 126
         return true;
127 127
       }
128 128
     }, ARRAY_FILTER_USE_BOTH);
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
   public function getAnswers($bhvrs) {
141 141
     $answers = [];
142 142
     $user_bhvrs = array_combine($this->getUserBehaviorProps(), $bhvrs);
143
-    foreach($user_bhvrs as $property => $user_bhvr) {
143
+    foreach ($user_bhvrs as $property => $user_bhvr) {
144 144
       $behavior_id = intval(substr($property, -1, 1));
145
-      foreach($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) {
145
+      foreach ($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) {
146 146
         $question_id = \common\models\Question::$TYPES[$answer_letter];
147 147
         array_push($answers, [
148 148
                                'behavior_id'    => $user_bhvr->behavior_id,
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
   public function saveAnswers(int $user_id, array $bhvrs) {
160 160
     $result = true;
161 161
 
162
-    foreach($this->getAnswers($bhvrs) as $answer) {
162
+    foreach ($this->getAnswers($bhvrs) as $answer) {
163 163
       $model = Yii::$container->get(\common\interfaces\QuestionInterface::class);
164 164
       $model->user_id = $user_id;
165 165
       $model->behavior_id = $answer['behavior_id'];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
       $model->date = new Expression("now()::timestamp");
169 169
       $model->question = $answer['question_id'];
170 170
       $model->answer = $answer['answer'];
171
-      if(!$model->save()) {
171
+      if (!$model->save()) {
172 172
         $result = false;
173 173
       }
174 174
     }
Please login to merge, or discard this patch.
site/controllers/CheckinController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
   public function actionIndex() {
38 38
     $form = Yii::$container->get(\site\models\CheckinForm::class);
39 39
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
40
-      if(!$form->compileBehaviors()) {
40
+      if (!$form->compileBehaviors()) {
41 41
         return $this->redirect(['view']);
42 42
       }
43 43
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
       return $this->redirect(['questions']);
49 49
     }
50 50
 
51
-    $behaviors  = Yii::$container->get(BehaviorInterface::class)::$behaviors;
51
+    $behaviors = Yii::$container->get(BehaviorInterface::class)::$behaviors;
52 52
     $custom = \common\models\CustomBehavior::find(['user_id' => Yii::$app->user->identity->id])->asArray()->all();
53 53
     return $this->render('index', [
54 54
       'categories'    => Yii::$container->get(CategoryInterface::class)::$categories,
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     $date = Yii::$container->get(TimeInterface::class)->getLocalDate();
64 64
 
65 65
     $user_behaviors = $user_behavior->getUserBehaviorsWithCategory($date);
66
-    if(count($user_behaviors) === 0) {
66
+    if (count($user_behaviors) === 0) {
67 67
       return $this->redirect(['view']);
68 68
     }
69 69
 
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
       $form->deleteToday();
74 74
 
75 75
       $behaviors = $user_behavior->findAll($form->getUserBehaviorIds());
76
-      if($result = $form->saveAnswers(Yii::$app->user->identity->id, $behaviors)) {
76
+      if ($result = $form->saveAnswers(Yii::$app->user->identity->id, $behaviors)) {
77 77
 
78
-        if(Yii::$app->user->identity->send_email) {
79
-          if(Yii::$app->user->identity->sendEmailReport($date)) {
78
+        if (Yii::$app->user->identity->send_email) {
79
+          if (Yii::$app->user->identity->sendEmailReport($date)) {
80 80
             Yii::$app->session->setFlash('success', 'Your check-in is complete. A notification has been sent to your report partners.');
81 81
           } else {
82 82
             Yii::$app->session->setFlash('success', 'Your check-in is complete.');
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     $raw_pie_data  = $user_behavior::decorate($user_behavior->getBehaviorsWithCounts());
133 133
     $answer_pie    = $user_behavior->getBehaviorsByCategory($raw_pie_data);
134 134
 
135
-    $pie_data   = [
135
+    $pie_data = [
136 136
       "labels"   => array_column($answer_pie, "name"),
137 137
       "datasets" => [[
138 138
           "data"                 => array_map('intval', array_column($answer_pie, "count")),
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
     $checkins = $user_behavior->getCheckInBreakdown($period);
168 168
 
169 169
     $accum = [];
170
-    foreach($checkins as $date => $cats) {
171
-      for($i = 1; $i <= 7; $i ++) {
170
+    foreach ($checkins as $date => $cats) {
171
+      for ($i = 1; $i <= 7; $i++) {
172 172
         $accum[$i][] = array_key_exists($i, $cats) ? $cats[$i]['count'] : [];
173 173
       }
174 174
     }
175 175
 
176 176
     $bar_datasets = [];
177
-    foreach($accum as $idx => $data) {
177
+    foreach ($accum as $idx => $data) {
178 178
       $bar_datasets[] = [
179 179
         'label' => ($category::getCategories())[$idx],
180 180
         'backgroundColor' => $category::$colors[$idx]['color'],
Please login to merge, or discard this patch.