Passed
Pull Request — master (#177)
by Corey
02:57
created
common/tests/unit/components/TimeTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
       $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior');
25 25
       $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion');
26 26
 
27
-      $this->container->set('common\interfaces\TimeInterface', function () {
27
+      $this->container->set('common\interfaces\TimeInterface', function() {
28 28
         return new \common\components\Time('America/Los_Angeles');
29 29
       });
30 30
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
     public function testGetLocalTime()
49 49
     {
50
-      $this->specify('getLocalTime should function correctly', function () {
50
+      $this->specify('getLocalTime should function correctly', function() {
51 51
         expect("getLocalTime should work with user's set time", $this->assertEquals($this->time->getLocalTime(), (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s")));
52 52
         expect('getLocalTime should work with a custom timezone', $this->assertEquals($this->time->getLocalTime("UTC"), (new DateTime("now"))->format("Y-m-d H:i:s")));
53 53
       });
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function testConvertLocalToUTC()
57 57
     {
58
-      $this->specify('convertLocalToUTC should function correctly', function () {
58
+      $this->specify('convertLocalToUTC should function correctly', function() {
59 59
         $la_tz = (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s");
60 60
 
61 61
         expect('convertLocalToUTC should convert a Los Angeles tz to UTC with the included time', $this->assertEquals($this->time->convertLocalToUTC($la_tz), (new DateTime("now"))->format("Y-m-d H:i:s")));
62 62
         expect('convertLocalToUTC should convert a Los Angeles tz to UTC without the included time', $this->assertEquals($this->time->convertLocalToUTC($la_tz, false), (new DateTime("now"))->format("Y-m-d")));
63 63
         // with UTC
64
-        $this->container->set('common\interfaces\TimeInterface', function () {
64
+        $this->container->set('common\interfaces\TimeInterface', function() {
65 65
           return new \common\components\Time('UTC');
66 66
         });
67 67
         $time = $this->container->get('common\interfaces\TimeInterface');
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 
75 75
     public function testConvertUTCToLocal()
76 76
     {
77
-      $this->specify('convertUTCToLocal should function correctly', function () {
77
+      $this->specify('convertUTCToLocal should function correctly', function() {
78 78
         $utc_tz = (new DateTime("now"))->format("Y-m-d H:i:s");
79 79
 
80 80
         expect('convertUTCToLocal should convert a UTC tz to Los Angeles with the included timezone', $this->assertEquals((new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format(DateTime::ATOM), $this->time->convertUTCToLocal($utc_tz)));
81 81
         expect('convertUTCToLocal should convert a UTC tz to Los Angeles without the included timezone', $this->assertEquals($this->time->convertUTCToLocal($utc_tz, false), (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s")));
82 82
 
83 83
         // with UTC
84
-        $this->container->set('common\interfaces\TimeInterface', function () {
84
+        $this->container->set('common\interfaces\TimeInterface', function() {
85 85
           return new \common\components\Time('UTC');
86 86
         });
87 87
         $time = $this->container->get('common\interfaces\TimeInterface');
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
     public function testGetLocalDate()
96 96
     {
97
-      $this->specify('getLocalDate should function correctly', function () {
97
+      $this->specify('getLocalDate should function correctly', function() {
98 98
         expect("getLocalDate should correctly get the user's local date", $this->assertEquals($this->time->getLocalDate(), (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d")));
99 99
         expect("getLocalDate should correctly get the local date of a specified timezone", $this->assertEquals($this->time->getLocalDate("UTC"), (new DateTime("now", new DateTimeZone("UTC")))->format("Y-m-d")));
100 100
       });
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         expect('getUTCBookends should return false if there is a space at the end of the time string', $this->assertFalse($this->time->getUTCBookends('2016-05-30 00:00:00 ')));
117 117
         expect('getUTCBookends should return UTC bookend times from the Los_Angeles tz', $this->assertEquals($this->time->getUTCBookends('2016-05-30'), ['2016-05-30 07:00:00', '2016-05-31 06:59:59']));
118 118
         // with UTC
119
-        $this->container->set('common\interfaces\TimeInterface', function () {
119
+        $this->container->set('common\interfaces\TimeInterface', function() {
120 120
           return new \common\components\Time('UTC');
121 121
         });
122 122
         $time = $this->container->get('common\interfaces\TimeInterface');
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
       $tz = 'America/Los_Angeles';
204 204
       $this->time->timezone = 'America/Los_Angeles';
205 205
 
206
-      $today =  new \DateTime("now + 1 day", new \DateTimeZone($tz)); // we do an extra day to include today as the last day
206
+      $today = new \DateTime("now + 1 day", new \DateTimeZone($tz)); // we do an extra day to include today as the last day
207 207
       $should_be_today = $this->time->getDateTimesInPeriod()->getEndDate();
208 208
       expect('getDateTimesInPeriod should return a list of \DatePeriods, the last being for today', $this->assertEquals($today->format('Y-m-d H'), $should_be_today->format('Y-m-d H')));
209 209
 
210
-      $start =  new \DateTime("30 days ago", new \DateTimeZone($tz));
210
+      $start = new \DateTime("30 days ago", new \DateTimeZone($tz));
211 211
       $should_be_start = $this->time->getDateTimesInPeriod()->getStartDate();
212 212
       expect('getDateTimesInPeriod should return a list of \DatePeriods, the first being for 30 days ago (by default)', $this->assertEquals($start->format('Y-m-d H'), $should_be_start->format('Y-m-d H')));
213 213
     }
Please login to merge, or discard this patch.
site/views/profile/index.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,11 +71,11 @@
 block discarded – undo
71 71
 ]); ?>
72 72
             <?= $form->field($profile, 'timezone')->dropDownList(array_combine($timezones, $timezones)); ?>
73 73
             <?= $form->field($profile, 'expose_graph')->checkbox() ?>
74
-            <?php if($profile->expose_graph): ?>
74
+            <?php if ($profile->expose_graph): ?>
75 75
             <div class='alert alert-success behaviors-graph-info'>Your behaviors graph can be found at:<br /> <a id="behaviors-graph-link" target="_blank" href="<?=$graph_url?>"><?=$graph_url?></a></div>
76 76
             <?php endif; ?>
77 77
             <?= $form->field($profile, 'send_email')->checkbox() ?>
78
-            <div id='send_email_fields' <?php if(!$profile->send_email) { ?>style="display: none;"<?php } ?>>
78
+            <div id='send_email_fields' <?php if (!$profile->send_email) { ?>style="display: none;"<?php } ?>>
79 79
               <?= $form->field($profile, 'email_category')->dropdownList(Category::getCategories(), ['data-toggle' => 'tooltip', 'data-placement' => 'left', 'data-trigger' => 'hover', 'data-delay' => '{"show": 500, "hide": 100}', 'title' => 'Want to send an email with every check-in? Try setting this to "Restoration"']) ?>
80 80
               <?= $form->field($profile, 'partner_email1')->input('email'); ?>
81 81
               <?= $form->field($profile, 'partner_email2')->input('email'); ?>
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
@@ -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.
site/models/CheckinForm.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
   public function setBehaviors($behaviors) {
58 58
     foreach($behaviors as $category_id => $bhvr_set) {
59 59
       $attribute = "behaviors$category_id";
60
-			$this->$attribute = [];
60
+      $this->$attribute = [];
61 61
       foreach($bhvr_set as $behavior) {
62 62
         $this->{$attribute}[] = $behavior['id'];
63 63
       }
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 
77 77
   public function compileBehaviors() {
78 78
     $behaviors = array_merge((array)$this->behaviors1,
79
-                           (array)$this->behaviors2,
80
-                           (array)$this->behaviors3,
81
-                           (array)$this->behaviors4,
82
-                           (array)$this->behaviors5,
83
-                           (array)$this->behaviors6,
84
-                           (array)$this->behaviors7);
79
+                            (array)$this->behaviors2,
80
+                            (array)$this->behaviors3,
81
+                            (array)$this->behaviors4,
82
+                            (array)$this->behaviors5,
83
+                            (array)$this->behaviors6,
84
+                            (array)$this->behaviors7);
85 85
 
86 86
     return array_filter($behaviors); // strip out false values
87 87
   }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
   }
56 56
 
57 57
   public function setBehaviors($behaviors) {
58
-    foreach($behaviors as $category_id => $bhvr_set) {
58
+    foreach ($behaviors as $category_id => $bhvr_set) {
59 59
       $attribute = "behaviors$category_id";
60 60
 			$this->$attribute = [];
61
-      foreach($bhvr_set as $behavior) {
61
+      foreach ($bhvr_set as $behavior) {
62 62
         $this->{$attribute}[] = $behavior['id'];
63 63
       }
64 64
     }   
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 
67 67
   public function validateBehaviors($attribute, $params) {
68 68
     if (!$this->hasErrors()) {
69
-      foreach($this->$attribute as $behavior) {
70
-        if(!is_numeric($behavior)) {
69
+      foreach ($this->$attribute as $behavior) {
70
+        if (!is_numeric($behavior)) {
71 71
           $this->addError($attribute, 'One of your behaviors is not an integer!');
72 72
         }
73 73
       }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
     // delete cached behaviors
107 107
     array_map(function($period) use ($time) {
108
-      $key = "checkins_".Yii::$app->user->id."_{$period}_".$time->getLocalDate();
108
+      $key = "checkins_" . Yii::$app->user->id . "_{$period}_" . $time->getLocalDate();
109 109
       Yii::$app->cache->delete($key);
110 110
     }, [30, 90, 180]);
111 111
   }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
   public function mergeWithDefault(array $user_behaviors) {
121 121
     $behaviors = AH::index(Yii::$container->get(BehaviorInterface::class)::$behaviors, 'name', "category_id");
122 122
     array_walk($behaviors, function(&$bhvrs, $cat_id) use ($user_behaviors) {
123
-      if(array_key_exists($cat_id, $user_behaviors)) {
123
+      if (array_key_exists($cat_id, $user_behaviors)) {
124 124
         $bhvrs = AH::merge($bhvrs, $user_behaviors[$cat_id]);
125 125
       }
126 126
     });
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
   }
129 129
 
130 130
   public function save() {
131
-    if(empty($this->compiled_behaviors)) {
131
+    if (empty($this->compiled_behaviors)) {
132 132
       $this->commpiled_behaviors = $this->compileBehaviors();
133 133
     }
134 134
 
135 135
     $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class);
136 136
 
137 137
     $rows = [];
138
-    foreach($this->compiled_behaviors as $behavior_id) {
138
+    foreach ($this->compiled_behaviors as $behavior_id) {
139 139
       $behavior_id = (int)$behavior_id;
140 140
       $behavior = \common\models\Behavior::getBehavior('id', $behavior_id);
141 141
       $category_id = $behavior['category_id'];
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
       )->execute();
159 159
 
160 160
     // if the user has publicised their check-in graph, create the image
161
-    if(Yii::$app->user->identity->expose_graph) {
161
+    if (Yii::$app->user->identity->expose_graph) {
162 162
       $checkins_last_month = $user_behavior->getCheckInBreakdown();
163 163
 
164
-      if($checkins_last_month) {
164
+      if ($checkins_last_month) {
165 165
         Yii::$container
166 166
           ->get(\common\components\Graph::class, [Yii::$app->user->identity])
167 167
           ->create($checkins_last_month, true);
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
@@ -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,
@@ -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($behaviors)) {
76
+      if ($result = $form->saveAnswers($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.');
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     $raw_pie_data  = $user_behavior::decorate($user_behavior->getBehaviorsWithCounts());
132 132
     $answer_pie    = $user_behavior->getBehaviorsByCategory($raw_pie_data);
133 133
 
134
-    $pie_data   = [
134
+    $pie_data = [
135 135
       "labels"   => array_column($answer_pie, "name"),
136 136
       "datasets" => [[
137 137
           "data"                 => array_map('intval', array_column($answer_pie, "count")),
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
     $checkins = $user_behavior->getCheckInBreakdown($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.