Completed
Push — master ( 42d56d...da4528 )
by Corey
03:35
created
common/tests/unit/data/behaviorsWithCounts.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -337,7 +337,7 @@
 block discarded – undo
337 337
   ], [
338 338
   ], [
339 339
   ], [
340
-  ], [ [
340
+  ], [[
341 341
       'user_id' => 1,
342 342
       'behavior_id' => 117,
343 343
       'count' => 1,
Please login to merge, or discard this patch.
common/tests/unit/models/UserBehaviorTest.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -105,19 +105,19 @@  discard block
 block discarded – undo
105 105
     expect('decorate should add Behavior data and Category data to an array of UserBehaviors',
106 106
       $this->assertEquals(
107 107
         $this->user_behavior->decorateWithCategory($this->singleSimpleBehaviorNoBehavior),
108
-         [['id' => 396,
109
-           'user_id' => 2,
110
-           'behavior_id' => 107,
111
-           'date' => '2016-06-17 04:12:43',
112
-           'behavior' => [
113
-             'id' => 107,
114
-             'name' => 'numb',
115
-             'category_id' => 6,
116
-             'category' => [
117
-               'id' => 6,
118
-               'name' => 'Exhausted',
119
-             ]
120
-           ]]]));
108
+          [['id' => 396,
109
+            'user_id' => 2,
110
+            'behavior_id' => 107,
111
+            'date' => '2016-06-17 04:12:43',
112
+            'behavior' => [
113
+              'id' => 107,
114
+              'name' => 'numb',
115
+              'category_id' => 6,
116
+              'category' => [
117
+                'id' => 6,
118
+                'name' => 'Exhausted',
119
+              ]
120
+            ]]]));
121 121
   }
122 122
 
123 123
   public function testGetBehaviorsByCategory() {
@@ -198,6 +198,6 @@  discard block
 block discarded – undo
198 198
     $bhvrs = require(__DIR__.'/../data/behaviorsWithCounts.php');
199 199
     $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php');
200 200
     $this->user_behavior->method('getBehaviorsWithCounts')->willReturn(...$bhvrs);
201
-		expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown()));
201
+    expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown()));
202 202
   }
203 203
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
   ]; 
34 34
   public function setUp() {
35 35
     // pull in test data
36
-    $data = require(__DIR__.'/../data/checkinData.php');
36
+    $data = require(__DIR__ . '/../data/checkinData.php');
37 37
     $this->singleBhvr = $data['singleBhvr'];
38 38
     $this->manyBhvrs = $data['manyBhvrs'];
39 39
     $this->allBhvrs = $data['allBhvrs'];
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser');
44 44
     $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion');
45 45
     $this->container->set('common\interfaces\BehaviorInterface', 'common\models\Behavior');
46
-    $this->container->set('common\interfaces\TimeInterface', function () {
46
+    $this->container->set('common\interfaces\TimeInterface', function() {
47 47
         return new \common\components\Time('America/Los_Angeles');
48 48
       });
49 49
 
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
                             ->setMethods(['getIsNewRecord', 'save', 'getBehaviorsByDate', 'getBehaviorsWithCounts'])
196 196
                             ->getMock();
197 197
 
198
-    $bhvrs = require(__DIR__.'/../data/behaviorsWithCounts.php');
199
-    $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php');
198
+    $bhvrs = require(__DIR__ . '/../data/behaviorsWithCounts.php');
199
+    $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php');
200 200
     $this->user_behavior->method('getBehaviorsWithCounts')->willReturn(...$bhvrs);
201 201
 		expect('asdf', $this->assertEquals($expected, $this->user_behavior->getCheckinBreakdown()));
202 202
   }
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
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
                                                 <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">
125 125
 
126 126
 <?php
127
-if($questions) {
128
-  foreach($questions as $behavior_id => $behavior_questions) {
127
+if ($questions) {
128
+  foreach ($questions as $behavior_id => $behavior_questions) {
129 129
 ?>
130 130
 
131 131
                                                    <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"> <?= $behavior_questions['question']['title'] ?> </h4>
132 132
 
133 133
 <?php
134
-    foreach($behavior_questions['answers'] as $key => $question) {  ?>
134
+    foreach ($behavior_questions['answers'] as $key => $question) {  ?>
135 135
       <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><?=$question['title']?></strong> <?=$question['answer']?></p>
136 136
 <?php
137 137
     }
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
                                                 <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">
189 189
 
190 190
 <?php
191
-if($user_behaviors) {
192
-  foreach($user_behaviors as $user_behavior) { ?>
191
+if ($user_behaviors) {
192
+  foreach ($user_behaviors as $user_behavior) { ?>
193 193
         <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">
194 194
           <strong style="color:#37b98f"><?= $user_behavior['category_name'] ?></strong>
195 195
 <?php
196
-    foreach($user_behavior['behaviors'] as $behavior) { ?>
196
+    foreach ($user_behavior['behaviors'] as $behavior) { ?>
197 197
         <br><?= $behavior['name'] ?>
198 198
 <?php
199 199
     }
Please login to merge, or discard this patch.
site/models/EditProfileForm.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
   }
54 54
 
55 55
   /**
56
-     * @codeCoverageIgnore
57
-     */
56
+   * @codeCoverageIgnore
57
+   */
58 58
   public function attributeLabels() {
59 59
     return [
60 60
       'partner_email1' => "Partner Email #1",
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
         // generate scores graph image
87 87
         $checkins_last_month = (Yii::$container->get(\common\interfaces\UserBehaviorInterface::class))
88
-                                               ->getCheckInBreakdown();
88
+                                                ->getCheckInBreakdown();
89 89
 
90 90
         // if they haven't done a check-in in the last month this will explode
91 91
         // 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
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
       $graph = Yii::$container
78 78
         ->get(\common\components\Graph::class, [$this->user]);
79 79
 
80
-      if($this->timezone) {
80
+      if ($this->timezone) {
81 81
         $user->timezone = $this->timezone;
82 82
       }
83
-      if($this->expose_graph) {
83
+      if ($this->expose_graph) {
84 84
         $user->expose_graph = true;
85 85
 
86 86
         // generate scores graph image
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         // if they haven't done a check-in in the last month this will explode
91 91
         // because $checkins_last_month is an empty array
92
-        if($checkins_last_month) {
92
+        if ($checkins_last_month) {
93 93
           $graph->create($checkins_last_month, true);
94 94
         }
95 95
       } else {
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         $graph->destroy();
99 99
       }
100 100
 
101
-      if($this->send_email) {
101
+      if ($this->send_email) {
102 102
         $user->send_email = true;
103 103
         $user->partner_email1  = $this->partner_email1;
104 104
         $user->partner_email2  = $this->partner_email2;
Please login to merge, or discard this patch.
common/components/Graph.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
   public function getFilepath() {
29 29
     $path = Yii::getAlias('@graphImgPath');
30 30
     $filename = $this->user->getIdHash() . ".png";
31
-    return $path. '/' . $filename;
31
+    return $path . '/' . $filename;
32 32
   }
33 33
 
34 34
   /**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
    * @return string the encoded image
62 62
    */
63 63
   public function create(array $checkins, bool $toDisk = false) {
64
-    if($toDisk) {
64
+    if ($toDisk) {
65 65
       // wipe out the current image, if it exists
66 66
       $this->destroy();
67 67
     }
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 
82 82
     // Setup dates as labels on the X-axis
83 83
     $graph->xaxis->SetTickLabels(array_keys($checkins));
84
-    $graph->xaxis->HideTicks(false,false);
84
+    $graph->xaxis->HideTicks(false, false);
85 85
 
86 86
     $graph->yaxis->scale->SetAutoMin(0);
87 87
     $graph->yaxis->HideLine(false);
88
-    $graph->yaxis->HideTicks(false,false);
88
+    $graph->yaxis->HideTicks(false, false);
89 89
     $graph->xaxis->SetLabelAngle(45);
90 90
     $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 10);
91 91
     $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 15);
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 
94 94
     // format the data into something nicer
95 95
     $accum = [];
96
-    foreach($checkins as $checkin_sum) {
97
-      for($i = 1; $i <= 7; $i ++) {
96
+    foreach ($checkins as $checkin_sum) {
97
+      for ($i = 1; $i <= 7; $i++) {
98 98
         $accum[$i][] = array_key_exists($i, $checkin_sum) ? $checkin_sum[$i]['count'] : 0;
99 99
       }
100 100
     }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     // Create the bar plots
103 103
     $plots = [];
104 104
     $category = Yii::$container->get(\common\interfaces\CategoryInterface::class);
105
-    foreach($accum as $category_key => $category_data) {
105
+    foreach ($accum as $category_key => $category_data) {
106 106
       $bplot = new BarPlot($category_data);
107 107
       $color = $category::$colors[$category_key]['color'];
108 108
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     $graph->Add($gbbplot);
118 118
 
119 119
     $graph->legend->SetColumns(3);
120
-    $graph->legend->SetPos(0.5,0.98,'center','bottom'); // position it at the center, just above the bottom edge
120
+    $graph->legend->SetPos(0.5, 0.98, 'center', 'bottom'); // position it at the center, just above the bottom edge
121 121
 
122 122
     $img = $graph->Stroke(_IMG_HANDLER);
123 123
 
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
     imagepng($img);
126 126
     $img_data = ob_get_clean();
127 127
 
128
-    if($toDisk) {
128
+    if ($toDisk) {
129 129
       $filepath = $this->getFilepath(); 
130
-      if(!is_dir(dirname($filepath))) {
130
+      if (!is_dir(dirname($filepath))) {
131 131
         mkdir(dirname($filepath), 0766, true);
132 132
       }
133 133
 
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
 
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 
128 128
   public function getCheckinBreakdown(int $period = 30) {
129 129
     $datetimes = $this->time->getDateTimesInPeriod($period);
130
-    $key = "scores_of_last_month_".Yii::$app->user->id."_{$period}_".$this->time->getLocalDate();
130
+    $key = "scores_of_last_month_" . Yii::$app->user->id . "_{$period}_" . $this->time->getLocalDate();
131 131
     $scores = Yii::$app->cache->get($key);
132 132
 
133
-    if($scores === false) {
133
+    if ($scores === false) {
134 134
       $scores = [];
135
-      foreach($datetimes as $datetime) {
135
+      foreach ($datetimes as $datetime) {
136 136
         $behaviors = self::decorateWithCategory($this->getBehaviorsWithCounts($datetime));
137 137
         $scores[$datetime->format('Y-m-d')] = $this->getBehaviorsByCategory($behaviors);
138 138
       }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
   public function getBehaviorsByCategory(array $decorated_behaviors) {
159 159
     $arr = array_reduce($decorated_behaviors, function($acc, $row) {
160 160
       $cat_id = $row['behavior']['category']['id'];
161
-      if(array_key_exists($cat_id, $acc)) {
161
+      if (array_key_exists($cat_id, $acc)) {
162 162
         $acc[$cat_id]['count'] += $row['count'];
163 163
       } else {
164 164
         $acc[$cat_id] = [
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
   }
176 176
 
177 177
   public static function decorate(array $uo, $with_category = false) {
178
-    foreach($uo as &$o) {
179
-      if($behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id'])) {
178
+    foreach ($uo as &$o) {
179
+      if ($behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id'])) {
180 180
         $o['behavior'] = $behavior;
181
-        if($with_category) {
181
+        if ($with_category) {
182 182
           $o['behavior']['category'] = \common\models\Category::getCategory('id', $o['behavior']['category_id']);
183 183
         }
184 184
       }
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
       ->having('user_id = :user_id')
205 205
       ->orderBy('count DESC');
206 206
 
207
-    if($limit instanceof \DateTime) {
207
+    if ($limit instanceof \DateTime) {
208 208
       list($start, $end) = $this->time->getUTCBookends($limit->format('Y-m-d'));
209 209
       $query->params += [':start_date' => $start, ':end_date' => $end];
210 210
       $query->where('user_id=:user_id AND date > :start_date AND date <= :end_date');
211
-    } else if(is_int($limit)) {
211
+    } else if (is_int($limit)) {
212 212
       $query->limit($limit);
213 213
     }
214 214
 
Please login to merge, or discard this patch.