Completed
Pull Request — master (#163)
by Corey
04:29 queued 02:02
created
common/models/LoginForm.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,10 +60,10 @@
 block discarded – undo
60 60
    */
61 61
   public function login()
62 62
   {
63
-    if($this->validate()) {
63
+    if ($this->validate()) {
64 64
       $user = $this->getUser();
65
-      if($user->isVerified()) {
66
-        return Yii::$app->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0);
65
+      if ($user->isVerified()) {
66
+        return Yii::$app->user->login($user, $this->rememberMe ? 3600*24*30 : 0);
67 67
       } else {
68 68
         Yii::$app->session->setFlash('warning', 'You must verify your account before you can proceed. Please check your email inbox for a verification email and follow the instructions.');
69 69
       }
Please login to merge, or discard this patch.
site/tests/unit/models/EditProfileFormTest.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
 use \site\models\EditProfileForm;
7 7
 
8 8
 class EditProfileFormTest extends \Codeception\Test\Unit {
9
-	public $values = [
10
-			'timezone' => 'America/Los_Angeles',
9
+  public $values = [
10
+      'timezone' => 'America/Los_Angeles',
11 11
       'send_email' => true,
12
-			'partner_email1' => '[email protected]',
13
-			'partner_email2' => '[email protected]',
14
-			'partner_email3' => '[email protected]',
15
-		];
12
+      'partner_email1' => '[email protected]',
13
+      'partner_email2' => '[email protected]',
14
+      'partner_email3' => '[email protected]',
15
+    ];
16 16
 
17 17
   public function testLoadUser() {
18 18
     $user = $this->getUser();
@@ -35,20 +35,20 @@  discard block
 block discarded – undo
35 35
 
36 36
     $form->attributes = $this->values;
37 37
     expect('saveProfile should return the user', $this->assertEquals($user, $form->saveProfile()));
38
-		expect('saveProfile should set the user\'s attributes to be the form values', $this->assertEquals($this->values, $user->attributes));
38
+    expect('saveProfile should set the user\'s attributes to be the form values', $this->assertEquals($this->values, $user->attributes));
39 39
 
40 40
     $form->send_email = 'not_a_boolean';
41 41
     expect('saveProfile should return the user with the partner-related settings equal to null', $this->assertNull($form->saveProfile()));
42 42
 
43
-		$null_vals = [
44
-			'partner_email1'  => null,
45
-			'partner_email2'  => null,
46
-			'partner_email3'  => null,
43
+    $null_vals = [
44
+      'partner_email1'  => null,
45
+      'partner_email2'  => null,
46
+      'partner_email3'  => null,
47 47
       'send_email'      => null,
48
-			'timezone'        => 'America/Los_Angeles',
49
-		];
48
+      'timezone'        => 'America/Los_Angeles',
49
+    ];
50 50
     $form->send_email = false;
51
-		$ret = $form->saveProfile();
51
+    $ret = $form->saveProfile();
52 52
     expect('saveProfile should return the user with the partner-related settings equal to null', $this->assertEquals($null_vals, $user->attributes));
53 53
 
54 54
     $form->send_email = 'not_a_boolean';
Please login to merge, or discard this patch.
common/models/UserBehavior.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
       ->groupBy('date, user_id')
85 85
       ->having('user_id = :user_id');
86 86
     $temp_dates = $query->all();
87
-    foreach($temp_dates as $temp_date) {
87
+    foreach ($temp_dates as $temp_date) {
88 88
       $past_checkin_dates[] = $this->time->convertUTCToLocal($temp_date['date']);
89 89
     }
90 90
 
@@ -126,16 +126,16 @@  discard block
 block discarded – undo
126 126
   }
127 127
 
128 128
   public function getCheckinBreakdown(\DatePeriod $datetimes) {
129
-    $key = "scores_of_last_month_".Yii::$app->user->id."_".$this->time->getLocalDate();
129
+    $key = "scores_of_last_month_" . Yii::$app->user->id . "_" . $this->time->getLocalDate();
130 130
     $scores = Yii::$app->cache->get($key);
131 131
 
132 132
     /******* REMOVE THIS ********/
133 133
     $scores = false;
134 134
     /******* END REMOVE THIS *******/
135 135
 
136
-    if($scores === false) {
136
+    if ($scores === false) {
137 137
       $scores = [];
138
-      foreach($datetimes as $datetime) {
138
+      foreach ($datetimes as $datetime) {
139 139
         $behaviors = self::decorateWithCategory($this->getBehaviorsWithCounts($datetime));
140 140
         $scores[$datetime->format('Y-m-d')] = $this->getBehaviorsByCategory($behaviors);
141 141
       }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
   public function getBehaviorsByCategory(array $decorated_behaviors) {
162 162
     $arr = array_reduce($decorated_behaviors, function($acc, $row) {
163 163
       $cat_id = $row['behavior']['category']['id'];
164
-      if(array_key_exists($cat_id, $acc)) {
164
+      if (array_key_exists($cat_id, $acc)) {
165 165
         $acc[$cat_id]['count'] += $row['count'];
166 166
       } else {
167 167
         $acc[$cat_id] = [
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
   }
179 179
 
180 180
   public static function decorate(array $uo, $with_category = false) {
181
-    foreach($uo as &$o) {
182
-      if($behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id'])) {
181
+    foreach ($uo as &$o) {
182
+      if ($behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id'])) {
183 183
         $o['behavior'] = $behavior;
184
-        if($with_category) {
184
+        if ($with_category) {
185 185
           $o['behavior']['category'] = \common\models\Category::getCategory('id', $o['behavior']['category_id']);
186 186
         }
187 187
       }
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
       ->having('user_id = :user_id')
203 203
       ->orderBy('count DESC');
204 204
 
205
-    if($limit instanceof \DateTime) {
205
+    if ($limit instanceof \DateTime) {
206 206
       list($start, $end) = $this->time->getUTCBookends($limit->format('Y-m-d'));
207 207
       $query->params += [':start_date' => $start, ':end_date' => $end];
208 208
       $query->where('user_id=:user_id AND date > :start_date AND date <= :end_date');
209
-    } else if(is_int($limit)) {
209
+    } else if (is_int($limit)) {
210 210
       $query->limit($limit);
211 211
     }
212 212
 
Please login to merge, or discard this patch.
site/views/profile/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
 ]); ?>
71 71
             <?= $form->field($profile, 'timezone')->dropDownList(array_combine($timezones, $timezones)); ?>
72 72
             <?= $form->field($profile, 'send_email')->checkbox() ?>
73
-            <div id='send_email_fields' <?php if(!$profile->send_email) { ?>style="display: none;"<?php } ?>>
73
+            <div id='send_email_fields' <?php if (!$profile->send_email) { ?>style="display: none;"<?php } ?>>
74 74
               <?= $form->field($profile, 'partner_email1')->input('email'); ?>
75 75
               <?= $form->field($profile, 'partner_email2')->input('email'); ?>
76 76
               <?= $form->field($profile, 'partner_email3')->input('email'); ?>
Please login to merge, or discard this patch.
site/controllers/CheckinController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
40 40
       $form->compiled_behaviors = $form->compileBehaviors();
41 41
 
42
-      if(sizeof($form->compiled_behaviors) === 0) {
42
+      if (sizeof($form->compiled_behaviors) === 0) {
43 43
         return $this->redirect(['view']);
44 44
       }
45 45
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
       return $this->redirect(['questions']);
51 51
     } else {
52
-      $behaviors  = Yii::$container->get(BehaviorInterface::class)::$behaviors;
52
+      $behaviors = Yii::$container->get(BehaviorInterface::class)::$behaviors;
53 53
       return $this->render('index', [
54 54
         'categories'    => Yii::$container->get(CategoryInterface::class)::$categories,
55 55
         'model'         => $form,
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     $date = Yii::$container->get(TimeInterface::class)->getLocalDate();
65 65
 
66 66
     $user_behaviors = $user_behavior->getUserBehaviorsWithCategory($date);
67
-    if(count($user_behaviors) === 0) {
67
+    if (count($user_behaviors) === 0) {
68 68
       return $this->redirect(['view']);
69 69
     }
70 70
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
       $form->deleteToday();
75 75
 
76 76
       $behaviors = $user_behavior->findAll($form->getUserBehaviorIds());
77
-      if($result = $form->saveAnswers($behaviors)) {
77
+      if ($result = $form->saveAnswers($behaviors)) {
78 78
 
79
-        if(Yii::$app->user->identity->send_email) {
79
+        if (Yii::$app->user->identity->send_email) {
80 80
           Yii::$app->user->identity->sendEmailReport($date);
81 81
           Yii::$app->session->setFlash('success', 'Your check-in is complete. A notification has been sent to your report partners.');
82 82
         } else {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     $raw_pie_data  = $user_behavior::decorateWithCategory($user_behavior->getBehaviorsWithCounts());
131 131
     $answer_pie    = $user_behavior->getBehaviorsByCategory($raw_pie_data);
132 132
 
133
-    $pie_data   = [
133
+    $pie_data = [
134 134
       "labels"   => array_column($answer_pie, "name"),
135 135
       "datasets" => [[
136 136
           "data"                 => array_map('intval', array_column($answer_pie, "count")),
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
     $checkins = $user_behavior->getCheckInBreakdown($time->getDateTimesInPeriod($period));
167 167
 
168 168
     $accum = [];
169
-    foreach($checkins as $date => $cats) {
170
-      for($i = 1; $i <= 7; $i ++) {
169
+    foreach ($checkins as $date => $cats) {
170
+      for ($i = 1; $i <= 7; $i++) {
171 171
         $accum[$i][] = array_key_exists($i, $cats) ? $cats[$i]['count'] : [];
172 172
       }
173 173
     }
174 174
 
175 175
     $bar_datasets = [];
176
-    foreach($accum as $idx => $data) {
176
+    foreach ($accum as $idx => $data) {
177 177
       $bar_datasets[] = [
178 178
         'label' => ($category::getCategories())[$idx],
179 179
         'backgroundColor' => $category::$colors[$idx]['color'],
Please login to merge, or discard this patch.