Completed
Push — master ( 818991...ace19a )
by Corey
03:14
created
site/models/EditProfileForm.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
   }
61 61
 
62 62
   /**
63
-     * @codeCoverageIgnore
64
-     */
63
+   * @codeCoverageIgnore
64
+   */
65 65
   public function attributeLabels() {
66 66
     return [
67 67
       'partner_email1' => "Partner Email #1",
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
         // generate behaviors graph image
95 95
         $checkins_last_month = (Yii::$container->get(\common\interfaces\UserBehaviorInterface::class))
96
-                                               ->getCheckInBreakdown();
96
+                                                ->getCheckInBreakdown();
97 97
 
98 98
         // if they haven't done a check-in in the last month this will explode
99 99
         // because $checkins_last_month is an empty array
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
       $graph = Yii::$container
86 86
         ->get(\common\components\Graph::class, [$this->user]);
87 87
 
88
-      if($this->timezone) {
88
+      if ($this->timezone) {
89 89
         $user->timezone = $this->timezone;
90 90
       }
91
-      if($this->expose_graph) {
91
+      if ($this->expose_graph) {
92 92
         $user->expose_graph = true;
93 93
 
94 94
         // generate behaviors graph image
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
         // if they haven't done a check-in in the last month this will explode
99 99
         // because $checkins_last_month is an empty array
100
-        if($checkins_last_month) {
100
+        if ($checkins_last_month) {
101 101
           $graph->create($checkins_last_month, true);
102 102
         }
103 103
       } else {
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         $graph->destroy();
107 107
       }
108 108
 
109
-      if($this->send_email) {
109
+      if ($this->send_email) {
110 110
         $user->send_email = true;
111 111
         $user->email_category = $this->email_category;
112 112
         $user->partner_email1 = $this->partner_email1;
Please login to merge, or discard this patch.
site/models/SignupForm.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
    */
90 90
   public function signup() {
91 91
     $user = $this->user->findByEmail($this->email);
92
-    if(!$user) {
92
+    if (!$user) {
93 93
       // this is a brand new user
94 94
       $this->user = $this->setFields($this->user);
95 95
       $this->user->save();
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
        * this is a user that for whatever reason is trying to sign up again
104 104
        * with the same email address.
105 105
        */
106
-      if(!$user->isTokenConfirmed()) {
106
+      if (!$user->isTokenConfirmed()) {
107 107
         /*
108 108
          * they've never verified their account. We don't care if their
109 109
          * verification token is current or expired. We're resetting their
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
       $user->generateAuthKey();
132 132
       $user->generateVerifyEmailToken();
133 133
 
134
-      if($user->send_email) {
134
+      if ($user->send_email) {
135 135
         $user->send_email = true;
136 136
         $user->email_category = $this->email_category;
137 137
         $user->partner_email1 = $this->partner_email1;
Please login to merge, or discard this patch.
site/assets/assets.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
  */
5 5
 
6 6
 // In the console environment, some path aliases may not exist. Please define these:
7
- Yii::setAlias('@webroot', __DIR__ . '/../web');
8
- Yii::setAlias('@web', '/');
7
+  Yii::setAlias('@webroot', __DIR__ . '/../web');
8
+  Yii::setAlias('@web', '/');
9 9
 
10 10
 $mainConf = require Yii::getAlias('@site/config/main.php');
11 11
 $converter = $mainConf['components']['assetManager']['converter'];
Please login to merge, or discard this patch.
site/tests/unit/models/QuestionFormTest.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
       $model->answer_2c = 'answering question c';
86 86
 
87 87
       expect('behaviorToAnswers should return the answer properties related to the behavior number supplied', $this->assertEquals($model->behaviorToAnswers(1), [
88
-                                                               'a' => 'answering question a',
89
-                                                               'b' => 'answering question b',
90
-                                                               'c' => 'answering question c'
91
-                                                             ]));
88
+                                                                'a' => 'answering question a',
89
+                                                                'b' => 'answering question b',
90
+                                                                'c' => 'answering question c'
91
+                                                              ]));
92 92
 
93 93
       expect('behaviorToAnswers should return the the empty set when there are no answers associated with the supplied behavior number', $this->assertEmpty($model->behaviorToAnswers(7)));
94 94
     });
@@ -117,60 +117,60 @@  discard block
 block discarded – undo
117 117
         $this->fakeModel(13, 281, 8),
118 118
         $this->fakeModel(28, 284, 8)
119 119
       ]), [ [
120
-										'behavior_id' => 280,
120
+                    'behavior_id' => 280,
121 121
                     'category_id' => 8,
122
-										'user_bhvr_id' => 7,
123
-										'question_id' => 1,
124
-										'answer' => 'processing emotions',
125
-									], [
126
-										'behavior_id' => 280,
122
+                    'user_bhvr_id' => 7,
123
+                    'question_id' => 1,
124
+                    'answer' => 'processing emotions',
125
+                  ], [
126
+                    'behavior_id' => 280,
127 127
                     'category_id' => 8,
128
-										'user_bhvr_id' => 7,
129
-										'question_id' => 2,
130
-										'answer' => 'processing emotions',
131
-									], [
132
-										'behavior_id' => 280,
128
+                    'user_bhvr_id' => 7,
129
+                    'question_id' => 2,
130
+                    'answer' => 'processing emotions',
131
+                  ], [
132
+                    'behavior_id' => 280,
133 133
                     'category_id' => 8,
134
-										'user_bhvr_id' => 7,
135
-										'question_id' => 3,
136
-										'answer' => 'processing emotions',
137
-									], [
138
-										'behavior_id' => 281,
134
+                    'user_bhvr_id' => 7,
135
+                    'question_id' => 3,
136
+                    'answer' => 'processing emotions',
137
+                  ], [
138
+                    'behavior_id' => 281,
139 139
                     'category_id' => 8,
140
-										'user_bhvr_id' => 13,
141
-										'question_id' => 1,
142
-										'answer' => 'processing emotions',
143
-									], [
144
-										'behavior_id' => 281,
140
+                    'user_bhvr_id' => 13,
141
+                    'question_id' => 1,
142
+                    'answer' => 'processing emotions',
143
+                  ], [
144
+                    'behavior_id' => 281,
145 145
                     'category_id' => 8,
146
-										'user_bhvr_id' => 13,
147
-										'question_id' => 2,
148
-										'answer' => 'processing emotions',
149
-									], [
150
-										'behavior_id' => 281,
146
+                    'user_bhvr_id' => 13,
147
+                    'question_id' => 2,
148
+                    'answer' => 'processing emotions',
149
+                  ], [
150
+                    'behavior_id' => 281,
151 151
                     'category_id' => 8,
152
-										'user_bhvr_id' => 13,
153
-										'question_id' => 3,
154
-										'answer' => 'processing emotions',
155
-									], [
156
-										'behavior_id' => 284,
152
+                    'user_bhvr_id' => 13,
153
+                    'question_id' => 3,
154
+                    'answer' => 'processing emotions',
155
+                  ], [
156
+                    'behavior_id' => 284,
157 157
                     'category_id' => 8,
158
-										'user_bhvr_id' => 28,
159
-										'question_id' => 1,
160
-										'answer' => 'processing emotions',
161
-									], [
162
-										'behavior_id' => 284,
158
+                    'user_bhvr_id' => 28,
159
+                    'question_id' => 1,
160
+                    'answer' => 'processing emotions',
161
+                  ], [
162
+                    'behavior_id' => 284,
163 163
                     'category_id' => 8,
164
-										'user_bhvr_id' => 28,
165
-										'question_id' => 2,
166
-										'answer' => 'processing emotions',
167
-									], [
168
-										'behavior_id' => 284,
164
+                    'user_bhvr_id' => 28,
165
+                    'question_id' => 2,
166
+                    'answer' => 'processing emotions',
167
+                  ], [
168
+                    'behavior_id' => 284,
169 169
                     'category_id' => 8,
170
-										'user_bhvr_id' => 28,
171
-										'question_id' => 3,
172
-										'answer' => 'processing emotions',
173
-									]]));
170
+                    'user_bhvr_id' => 28,
171
+                    'question_id' => 3,
172
+                    'answer' => 'processing emotions',
173
+                  ]]));
174 174
     });
175 175
   }
176 176
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
     $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser');
18 18
     $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior');
19 19
     $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion');
20
-    $this->container->set('common\interfaces\TimeInterface', function () {
20
+    $this->container->set('common\interfaces\TimeInterface', function() {
21 21
       return new \common\components\Time('America/Los_Angeles');
22 22
     });
23 23
   }
24 24
 
25 25
   public function testAttributeLabels()
26 26
   {
27
-    $this->specify('setBehaviors should function properly', function () {
27
+    $this->specify('setBehaviors should function properly', function() {
28 28
       $model = $this->container->get('\site\models\QuestionForm');
29 29
       expect('attributeLabels should be correct', $this->assertEquals($model->attributeLabels(), [
30 30
         'user_behavior_id1' => 'Restoration',
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     $model = $this->container->get('\site\models\QuestionForm');
44 44
     $validator = $model->getBhvrValidator();
45 45
 
46
-    $this->specify('getBhvrValidator should function properly', function () use($model, $validator) {
46
+    $this->specify('getBhvrValidator should function properly', function() use($model, $validator) {
47 47
       expect('getBhvrValidator should return false when nothing is set on the form', $this->assertFalse($validator($model, "user_behavior_id1")));
48 48
       expect('getBhvrValidator should return false when nothing is set on the form', $this->assertFalse($validator($model, "user_behavior_id7")));
49 49
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $this->fakeModel(7, 280, 8),
117 117
         $this->fakeModel(13, 281, 8),
118 118
         $this->fakeModel(28, 284, 8)
119
-      ]), [ [
119
+      ]), [[
120 120
 										'behavior_id' => 280,
121 121
                     'category_id' => 8,
122 122
 										'user_bhvr_id' => 7,
Please login to merge, or discard this patch.
site/views/checkin/report.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
                   <th>Behavior</th>
26 26
                   <th>Category</th>
27 27
               </tr>
28
-  <?php foreach($top_behaviors as $key => $row) {
28
+  <?php foreach ($top_behaviors as $key => $row) {
29 29
   $num = $key + 1;
30
-  print "<tr>".
31
-    "<td>{$row['count']}</td>".
32
-    "<td>{$row['behavior']['name']}</td>".
33
-    "<td>{$row['category']['name']}</td>".
30
+  print "<tr>" .
31
+    "<td>{$row['count']}</td>" .
32
+    "<td>{$row['behavior']['name']}</td>" .
33
+    "<td>{$row['category']['name']}</td>" .
34 34
     "</tr>";
35 35
   }
36 36
   ?>
Please login to merge, or discard this patch.
common/tests/unit/models/UserBehaviorTest.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -449,6 +449,6 @@
 block discarded – undo
449 449
     $bhvrs = require(__DIR__.'/../data/behaviorsWithCounts.php');
450 450
     $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php');
451 451
     $this->user_behavior->method('getBehaviorsWithCounts')->willReturn(...$bhvrs);
452
-		expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown()));
452
+    expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown()));
453 453
   }
454 454
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 
288 288
   public function setUp() {
289 289
     // pull in test data
290
-    $data = require(__DIR__.'/../data/checkinData.php');
290
+    $data = require(__DIR__ . '/../data/checkinData.php');
291 291
     $this->singleBhvr = $data['singleBhvr'];
292 292
     $this->manyBhvrs = $data['manyBhvrs'];
293 293
     $this->allBhvrs = $data['allBhvrs'];
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser');
298 298
     $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion');
299 299
     $this->container->set('common\interfaces\BehaviorInterface', 'common\models\Behavior');
300
-    $this->container->set('common\interfaces\TimeInterface', function () {
300
+    $this->container->set('common\interfaces\TimeInterface', function() {
301 301
         return new \common\components\Time('America/Los_Angeles');
302 302
       });
303 303
 
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
                             ->setMethods(['getIsNewRecord', 'save', 'getBehaviorsWithCounts'])
447 447
                             ->getMock();
448 448
 
449
-    $bhvrs = require(__DIR__.'/../data/behaviorsWithCounts.php');
450
-    $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php');
449
+    $bhvrs = require(__DIR__ . '/../data/behaviorsWithCounts.php');
450
+    $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php');
451 451
     $this->user_behavior->method('getBehaviorsWithCounts')->willReturn(...$bhvrs);
452 452
 		expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown()));
453 453
   }
Please login to merge, or discard this patch.
migrations/m190829_141748_alter_user_behavior_link_add_category_id.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,20 +22,20 @@
 block discarded – undo
22 22
 
23 23
       // then populate the columns
24 24
       $query = (new Query())->from('user_behavior_link');
25
-      foreach($query->batch() as $rows) {
26
-        foreach($rows as $row) {
25
+      foreach ($query->batch() as $rows) {
26
+        foreach ($rows as $row) {
27 27
           $bhvr = Behavior::getBehavior('id', $row['behavior_id']);
28
-          if($bhvr) {
28
+          if ($bhvr) {
29 29
             $this->update('{{%user_behavior_link}}', ['category_id' => $bhvr['category_id']], ['id' => $row['id']]);
30 30
           }
31 31
         }
32 32
       }
33 33
 
34 34
       $query = (new Query())->from('question');
35
-      foreach($query->batch() as $rows) {
36
-        foreach($rows as $row) {
35
+      foreach ($query->batch() as $rows) {
36
+        foreach ($rows as $row) {
37 37
           $bhvr = Behavior::getBehavior('id', $row['behavior_id']);
38
-          if($bhvr) {
38
+          if ($bhvr) {
39 39
             $this->update('{{%question}}', ['category_id' => $bhvr['category_id']], ['id' => $row['id']]);
40 40
           }
41 41
         }
Please login to merge, or discard this patch.
common/models/UserBehavior.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -196,7 +196,9 @@  discard block
 block discarded – undo
196 196
    * @return array
197 197
    */
198 198
   public function getByDate(int $user_id, $local_date = null) {
199
-    if(is_null($local_date)) $local_date = $this->time->getLocalDate();
199
+    if(is_null($local_date)) {
200
+      $local_date = $this->time->getLocalDate();
201
+    }
200 202
 
201 203
     $behaviors = $this->getBehaviorData($user_id, $local_date);
202 204
     $behaviors = self::decorate($behaviors);
@@ -241,7 +243,9 @@  discard block
 block discarded – undo
241 243
 
242 244
   // TODO: this should probably be a private method...but unit testing is hard
243 245
   public function parseBehaviorData($behaviors) {
244
-    if(!$behaviors) return [];
246
+    if(!$behaviors) {
247
+      return [];
248
+    }
245 249
 
246 250
     $bhvrs_by_cat = [];
247 251
     foreach($behaviors as $behavior) {
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
       ->groupBy('date, user_id')
92 92
       ->having('user_id = :user_id');
93 93
     $temp_dates = $query->all();
94
-    foreach($temp_dates as $temp_date) {
94
+    foreach ($temp_dates as $temp_date) {
95 95
       $past_checkin_dates[] = $this->time->convertUTCToLocal($temp_date['date']);
96 96
     }
97 97
 
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 
127 127
   public function getCheckinBreakdown(int $period = 30) {
128 128
     $datetimes = $this->time->getDateTimesInPeriod($period);
129
-    $key = "checkins_".Yii::$app->user->id."_{$period}_".$this->time->getLocalDate();
129
+    $key = "checkins_" . Yii::$app->user->id . "_{$period}_" . $this->time->getLocalDate();
130 130
     $checkins = Yii::$app->cache->get($key);
131 131
 
132
-    if($checkins === false) {
132
+    if ($checkins === false) {
133 133
       $checkins = [];
134
-      foreach($datetimes as $datetime) {
134
+      foreach ($datetimes as $datetime) {
135 135
         $behaviors = self::decorate($this->getBehaviorsWithCounts($datetime));
136 136
         $checkins[$datetime->format('Y-m-d')] = $this->getBehaviorsByCategory($behaviors);
137 137
       }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
   public function getBehaviorsByCategory(array $decorated_behaviors) {
158 158
     $arr = array_reduce($decorated_behaviors, function($acc, $row) {
159 159
       $cat_id = $row['category_id'];
160
-      if(array_key_exists($cat_id, $acc)) {
160
+      if (array_key_exists($cat_id, $acc)) {
161 161
         $acc[$cat_id]['count'] += $row['count'];
162 162
       } else {
163 163
         $acc[$cat_id] = [
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
       ->having('user_id = :user_id')
190 190
       ->orderBy('count DESC');
191 191
 
192
-    if($limit instanceof \DateTime) {
192
+    if ($limit instanceof \DateTime) {
193 193
       list($start, $end) = $this->time->getUTCBookends($limit->format('Y-m-d'));
194 194
       $query->params += [':start_date' => $start, ':end_date' => $end];
195 195
       $query->where('user_id=:user_id AND date > :start_date AND date <= :end_date');
196
-    } else if(is_int($limit)) {
196
+    } else if (is_int($limit)) {
197 197
       $query->limit($limit);
198 198
     }
199 199
     return $query->all();
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
    * @return array
212 212
    */
213 213
   public function getByDate(int $user_id, $local_date = null) {
214
-    if(is_null($local_date)) $local_date = $this->time->getLocalDate();
214
+    if (is_null($local_date)) $local_date = $this->time->getLocalDate();
215 215
 
216 216
     $behaviors = $this->getBehaviorData($user_id, $local_date);
217 217
     $behaviors = self::decorate($behaviors);
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
    * @return an array of decorated UserBehaviors, each with an added Category and Behavior
225 225
    */
226 226
   public static function decorate(array $uo) {
227
-    foreach($uo as &$o) {
227
+    foreach ($uo as &$o) {
228 228
       $behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id']);
229 229
       $category = \common\models\Category::getCategory('id', $o['category_id']);
230
-      if($behavior) {
230
+      if ($behavior) {
231 231
         $o['behavior'] = $behavior;
232 232
       } else if (array_key_exists('custom_behavior', $o)) {
233 233
         // if a behavior isn't set, this may be a custom_behavior
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
           'name' => $o['custom_behavior'],
237 237
         ];
238 238
       } // else -- something is weird
239
-      if($category) {
239
+      if ($category) {
240 240
         $o['category'] = $category;
241 241
       }
242 242
     }
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
 
263 263
   // TODO: this should probably be a private method...but unit testing is hard
264 264
   public function parseBehaviorData($behaviors) {
265
-    if(!$behaviors) return [];
265
+    if (!$behaviors) return [];
266 266
 
267 267
     $bhvrs_by_cat = [];
268
-    foreach($behaviors as $behavior) {
268
+    foreach ($behaviors as $behavior) {
269 269
       $indx = $behavior['category_id'];
270 270
 
271 271
       $bname = AH::getValue($behavior, 'behavior.name', AH::getValue($behavior, 'custom_behavior'));
Please login to merge, or discard this patch.
common/models/CustomBehavior.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -106,9 +106,9 @@
 block discarded – undo
106 106
       ], [
107 107
         'class' => 'kartik\grid\ActionColumn',
108 108
         'buttons' => [
109
-          'view' => function ($url, $model) { return ''; },
110
-          'update' => function ($url, $model) { return ''; },
111
-          'delete' => function ($url, $model) {
109
+          'view' => function($url, $model) { return ''; },
110
+          'update' => function($url, $model) { return ''; },
111
+          'delete' => function($url, $model) {
112 112
             return yii\helpers\Html::a('<span class="glyphicon glyphicon-remove"></span>', "/custom-behavior/delete?id={$model->id}", [
113 113
               'title' => 'Delete',
114 114
               'data-pjax' => true,
Please login to merge, or discard this patch.