Completed
Pull Request — master (#163)
by Corey
02:33
created
common/components/Controller.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@
 block discarded – undo
33 33
   {
34 34
     return [
35 35
       'error' => [
36
-         'class' => 'yii\web\ErrorAction',
37
-       ],
36
+          'class' => 'yii\web\ErrorAction',
37
+        ],
38 38
       'captcha' => [
39 39
         'class' => 'yii\captcha\CaptchaAction',
40 40
       ],
Please login to merge, or discard this patch.
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/controllers/CheckinController.php 1 patch
Spacing   +8 added lines, -8 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 {
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
     $categories = $category::getCategories();
130 130
 
131 131
     $accum = [];
132
-    foreach($scores as $date => $cats) {
133
-      for($i = 1; $i <= 7; $i ++) {
132
+    foreach ($scores as $date => $cats) {
133
+      for ($i = 1; $i <= 7; $i++) {
134 134
         $accum[$i][] = array_key_exists($i, $cats) ? $cats[$i]['count'] : [];
135 135
       }
136 136
     }
137 137
 
138 138
     $datasets = [];
139
-    foreach($accum as $idx => $data) {
139
+    foreach ($accum as $idx => $data) {
140 140
       $datasets[] = [
141 141
         'label' => $categories[$idx],
142 142
         'backgroundColor' => $category::$colors[$idx]['color'],
Please login to merge, or discard this patch.
site/tests/unit/models/EditProfileFormTest.php 2 patches
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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     $form->loadUser();
32 32
 
33 33
     Yii::$container
34
-      ->set(\common\interfaces\UserBehaviorInterface::class, function () { return new FakeUserBehavior(); });
34
+      ->set(\common\interfaces\UserBehaviorInterface::class, function() { return new FakeUserBehavior(); });
35 35
 
36 36
     $form->attributes = $this->values;
37 37
     expect('saveProfile should return the user', $this->assertEquals($user, $form->saveProfile()));
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,9 +126,9 @@  discard block
 block discarded – undo
126 126
   }
127 127
 
128 128
   public function calculateScoresOfLastMonth() {
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
-    if($scores === false) {
131
+    if ($scores === false) {
132 132
       $scores = [];
133 133
 
134 134
       $dt = new DateTime("now", new DateTimeZone("UTC"));
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
       $periods = new \DatePeriod($start, new \DateInterval('P1D'), $end);
139 139
       $local_tz = new \DateTimeZone($this->time->timezone);
140 140
       $scores = [];
141
-      foreach($periods as $period) {
141
+      foreach ($periods as $period) {
142 142
         $period->setTimezone($local_tz);
143 143
         $scores[$period->format('Y-m-d')] = $this->getBehaviorsByCategory($period);
144 144
       }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
     $arr = array_reduce($behaviors, function($acc, $row) {
167 167
       $cat_id = $row['behavior']['category']['id'];
168
-      if(array_key_exists($cat_id, $acc)) {
168
+      if (array_key_exists($cat_id, $acc)) {
169 169
         $acc[$cat_id]['count'] += $row['count'];
170 170
       } else {
171 171
         $acc[$cat_id] = [
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
   }
183 183
 
184 184
   public static function decorate(array $uo, $with_category = false) {
185
-    foreach($uo as &$o) {
186
-      if($behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id'])) {
185
+    foreach ($uo as &$o) {
186
+      if ($behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id'])) {
187 187
         $o['behavior'] = $behavior;
188
-        if($with_category) {
188
+        if ($with_category) {
189 189
           $o['behavior']['category'] = \common\models\Category::getCategory('id', $o['behavior']['category_id']);
190 190
         }
191 191
       }
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
       ->having('user_id = :user_id')
207 207
       ->orderBy('count DESC');
208 208
 
209
-    if($limit instanceof \DateTime) {
209
+    if ($limit instanceof \DateTime) {
210 210
       list($start, $end) = $this->time->getUTCBookends($limit->format('Y-m-d'));
211 211
       $query->params += [':start_date' => $start, ':end_date' => $end];
212 212
       $query->where('user_id=:user_id AND date > :start_date AND date <= :end_date');
213
-    } else if(is_int($limit)) {
213
+    } else if (is_int($limit)) {
214 214
       $query->limit($limit);
215 215
     }
216 216
 
Please login to merge, or discard this patch.