Completed
Push — master ( d9f9e5...54ca0d )
by Corey
02:49
created
site/tests/_support/UnitTester.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 {
21 21
     use _generated\UnitTesterActions;
22 22
 
23
-   /**
24
-    * Define custom actions here
25
-    */
23
+    /**
24
+     * Define custom actions here
25
+     */
26 26
 }
Please login to merge, or discard this patch.
common/models/Category.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@
 block discarded – undo
15 15
 
16 16
   // a weight of 0 means selections in that category do not increase the score
17 17
   public static $categories = [
18
-    [ "id" => 1, "weight" => 0,  "name" => "Restoration"],
19
-    [ "id" => 2, "weight" => 1,  "name" => "Forgetting Priorities"],
20
-    [ "id" => 3, "weight" => 2,  "name" => "Anxiety"],
21
-    [ "id" => 4, "weight" => 4,  "name" => "Speeding Up"],
22
-    [ "id" => 5, "weight" => 6,  "name" => "Ticked Off"],
23
-    [ "id" => 6, "weight" => 8,  "name" => "Exhausted"],
24
-    [ "id" => 7, "weight" => 10, "name" => "Relapse/Moral Failure"],
18
+    ["id" => 1, "weight" => 0, "name" => "Restoration"],
19
+    ["id" => 2, "weight" => 1, "name" => "Forgetting Priorities"],
20
+    ["id" => 3, "weight" => 2, "name" => "Anxiety"],
21
+    ["id" => 4, "weight" => 4, "name" => "Speeding Up"],
22
+    ["id" => 5, "weight" => 6, "name" => "Ticked Off"],
23
+    ["id" => 6, "weight" => 8, "name" => "Exhausted"],
24
+    ["id" => 7, "weight" => 10, "name" => "Relapse/Moral Failure"],
25 25
   ];
26 26
 
27 27
   public static $colors = [
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
@@ -35,12 +35,12 @@
 block discarded – undo
35 35
                 <th>Behavior</th>
36 36
                 <th>Category</th>
37 37
             </tr>
38
-<?php foreach($top_behaviors as $key => $row) {
38
+<?php foreach ($top_behaviors as $key => $row) {
39 39
 $num = $key + 1;
40
-print "<tr>".
41
-  "<td>{$row['count']}</td>".
42
-  "<td>{$row['behavior']['name']}</td>".
43
-  "<td>{$row['behavior']['category']['name']}</td>".
40
+print "<tr>" .
41
+  "<td>{$row['count']}</td>" .
42
+  "<td>{$row['behavior']['name']}</td>" .
43
+  "<td>{$row['behavior']['category']['name']}</td>" .
44 44
   "</tr>";
45 45
 }
46 46
 ?>
Please login to merge, or discard this patch.
common/tests/unit/components/TimeTest.php 1 patch
Spacing   +8 added lines, -8 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
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function testGetLocalTime()
42 42
     {
43
-      $this->specify('getLocalTime should function correctly', function () {
43
+      $this->specify('getLocalTime should function correctly', function() {
44 44
         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")));
45 45
         expect('getLocalTime should work with a custom timezone', $this->assertEquals($this->time->getLocalTime("UTC"), (new DateTime("now"))->format("Y-m-d H:i:s")));
46 46
       });
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 
49 49
     public function testConvertLocalToUTC()
50 50
     {
51
-      $this->specify('convertLocalToUTC should function correctly', function () {
51
+      $this->specify('convertLocalToUTC should function correctly', function() {
52 52
         $la_tz = (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s");
53 53
 
54 54
         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")));
55 55
         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")));
56 56
         // with UTC
57
-        $this->container->set('common\interfaces\TimeInterface', function () {
57
+        $this->container->set('common\interfaces\TimeInterface', function() {
58 58
           return new \common\components\Time('UTC');
59 59
         });
60 60
         $time = $this->container->get('common\interfaces\TimeInterface');
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 
68 68
     public function testConvertUTCToLocal()
69 69
     {
70
-      $this->specify('convertUTCToLocal should function correctly', function () {
70
+      $this->specify('convertUTCToLocal should function correctly', function() {
71 71
         $utc_tz = (new DateTime("now"))->format("Y-m-d H:i:s");
72 72
 
73 73
         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)));
74 74
         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")));
75 75
 
76 76
         // with UTC
77
-        $this->container->set('common\interfaces\TimeInterface', function () {
77
+        $this->container->set('common\interfaces\TimeInterface', function() {
78 78
           return new \common\components\Time('UTC');
79 79
         });
80 80
         $time = $this->container->get('common\interfaces\TimeInterface');
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
     public function testGetLocalDate()
89 89
     {
90
-      $this->specify('getLocalDate should function correctly', function () {
90
+      $this->specify('getLocalDate should function correctly', function() {
91 91
         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")));
92 92
         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")));
93 93
       });
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         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 ')));
110 110
         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']));
111 111
         // with UTC
112
-        $this->container->set('common\interfaces\TimeInterface', function () {
112
+        $this->container->set('common\interfaces\TimeInterface', function() {
113 113
           return new \common\components\Time('UTC');
114 114
         });
115 115
         $time = $this->container->get('common\interfaces\TimeInterface');
Please login to merge, or discard this patch.
common/config/main.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@
 block discarded – undo
10 10
       'common\interfaces\QuestionInterface' => \common\models\Question::class,
11 11
       'common\interfaces\BehaviorInterface' => \common\models\Behavior::class,
12 12
       'common\interfaces\CategoryInterface' => \common\models\Category::class,
13
-      'common\interfaces\TimeInterface' => function () {
14
-        if(Yii::$app->user->getIsGuest()) {
13
+      'common\interfaces\TimeInterface' => function() {
14
+        if (Yii::$app->user->getIsGuest()) {
15 15
           return new \common\components\Time('UTC');
16 16
         } else {
17 17
           return new \common\components\Time(Yii::$app->user->identity->timezone);
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,14 +49,14 @@  discard block
 block discarded – undo
49 49
 
50 50
       // delete cached scores
51 51
       $time = Yii::$container->get(\common\interfaces\TimeInterface::class);
52
-      $key = "scores_of_last_month_".Yii::$app->user->id."_".$time->getLocalDate();
52
+      $key = "scores_of_last_month_" . Yii::$app->user->id . "_" . $time->getLocalDate();
53 53
       Yii::$app->cache->delete($key);
54 54
 
55 55
       // if the user has publicised their score graph, create the image
56
-      if(Yii::$app->user->identity->expose_graph) {
56
+      if (Yii::$app->user->identity->expose_graph) {
57 57
         $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class);
58 58
         $scores_last_month = $user_behavior->calculateScoresOfLastMonth();
59
-        if($scores_last_month) {
59
+        if ($scores_last_month) {
60 60
           Yii::$container
61 61
             ->get(\common\components\Graph::class, [Yii::$app->user->identity])
62 62
             ->create($scores_last_month, true);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     $date = Yii::$container->get(\common\interfaces\TimeInterface::class)->getLocalDate();
82 82
 
83 83
     $user_behaviors = $user_behavior->getUserBehaviorsWithCategory($date);
84
-    if(count($user_behaviors) === 0) {
84
+    if (count($user_behaviors) === 0) {
85 85
       return $this->redirect(['view']);
86 86
     }
87 87
 
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
       $form->deleteToday();
92 92
 
93 93
       $behaviors = $user_behavior->findAll($form->getUserBehaviorIds());
94
-      if($result = $form->saveAnswers($behaviors)) {
94
+      if ($result = $form->saveAnswers($behaviors)) {
95 95
 
96 96
         $score = $user_behavior->getDailyScore();
97
-        if(Yii::$app->user->identity->isOverThreshold($score)) {
97
+        if (Yii::$app->user->identity->isOverThreshold($score)) {
98 98
           Yii::$app->user->identity->sendEmailReport($date);
99 99
           Yii::$app->session->setFlash('warning', 'Your check-in is complete. A notification has been sent to your report partners because of your high score. Reach out to them!');
100 100
         } else {
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
   public function actionView(string $date = null)
115 115
   {
116 116
     $time = Yii::$container->get(\common\interfaces\TimeInterface::class);
117
-    if(is_null($date)) {
117
+    if (is_null($date)) {
118 118
       $date = $time->getLocalDate();
119
-    } else if($dt = $time->parse($date)) {
119
+    } else if ($dt = $time->parse($date)) {
120 120
       $date = $dt->format('Y-m-d');
121 121
     } else {
122 122
       $date = $time->getLocalDate();
Please login to merge, or discard this patch.
site/views/checkin/old_view.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@
 block discarded – undo
92 92
     print $form
93 93
             ->field($model, "behaviors{$category['id']}")
94 94
             ->checkboxList($behaviors,
95
-                           ['item' => "checkboxItemTemplate"]);
95
+                            ['item' => "checkboxItemTemplate"]);
96 96
   }
97 97
   ActiveForm::end();
98 98
 
Please login to merge, or discard this patch.
Switch Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@
 block discarded – undo
41 41
 
42 42
   <?php
43 43
               switch(true) {
44
-                case ($score < 30):
45
-                  $alert_level = "success";
46
-                  $alert_msg = "You're doing well! Keep on doing whatever it is you're doing!";
47
-                  break;
44
+              case ($score < 30):
45
+                $alert_level = "success";
46
+                $alert_msg = "You're doing well! Keep on doing whatever it is you're doing!";
47
+                break;
48 48
 
49 49
               case ($score < 40):
50 50
                 $alert_level = "info";
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 $this->title = "The Faster Scale App | Previous Check-ins";
16 16
 $time = Yii::$container->get('common\interfaces\TimeInterface');
17 17
 $this->registerJsFile('/js/checkin/view.js', ['depends' => [\site\assets\AppAsset::class]]);
18
-if($answer_pie) {
18
+if ($answer_pie) {
19 19
   $this->registerJsFile('/js/checkin/charts/pie.js', ['depends' => [\site\assets\AppAsset::class]]);
20 20
 }
21 21
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 }
26 26
 
27 27
 $pie_data = [];
28
-if($answer_pie) {
28
+if ($answer_pie) {
29 29
   $values     = array_map('intval', array_column($answer_pie, "count"));
30 30
   $labels     = array_column($answer_pie, "name");
31 31
   $colors     = array_column($answer_pie, "color");
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
   <h1>View Previous Check-ins</h1>
52 52
 
53 53
   <?php
54
-              switch(true) {
54
+              switch (true) {
55 55
                 case ($score < 30):
56 56
                   $alert_level = "success";
57 57
                   $alert_msg = "You're doing well! Keep on doing whatever it is you're doing!";
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
 </div>
113 113
 
114 114
 
115
-  <?php if($questions) {
115
+  <?php if ($questions) {
116 116
   print "<h3>Processing Questions:</h3>";
117
-  foreach($questions as $behavior_id => $behavior_questions) {
117
+  foreach ($questions as $behavior_id => $behavior_questions) {
118 118
     print "<div class='well well-sm'>";
119 119
     print "<button type='button' class='btn btn-primary' disabled='disabled'>{$behavior_questions['question']['title']}</button>";
120 120
     print "<div class='row'>";
121
-    foreach($behavior_questions['answers'] as $question) { 
121
+    foreach ($behavior_questions['answers'] as $question) { 
122 122
       print "<div class='col-md-4'>";
123 123
       print "<p><strong>{$question['title']}</strong></p>";
124
-      print "<p>".Html::encode($question['answer'])."</p>";
124
+      print "<p>" . Html::encode($question['answer']) . "</p>";
125 125
       print "</div>";
126 126
     }
127 127
     print "</div></div>";
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     'options' => ['class' => 'form-horizontal'],
137 137
   ]);
138 138
 
139
-  foreach($categories as $category) {
139
+  foreach ($categories as $category) {
140 140
     $behaviors = AH::map($behaviorsList[$category['id']], 'id', 'name');
141 141
     print $form
142 142
             ->field($model, "behaviors{$category['id']}")
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
   ActiveForm::end();
147 147
 
148 148
 $this->registerJson($past_checkin_dates, "past-checkin-dates");
149
-if($answer_pie) {
149
+if ($answer_pie) {
150 150
   $this->registerJson($pie_data, "pie_data");
151 151
 }
152 152
 ?>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,9 +102,12 @@
 block discarded – undo
102 102
         <div class='card-text'>
103 103
           <?php if ($pie_data): ?>
104 104
           <canvas id='category-pie-chart'></canvas>
105
-          <?php else: ?>
105
+          <?php else {
106
+  : ?>
106 107
           <p>no data</p>
107
-          <?php endif; ?>
108
+          <?php endif;
109
+}
110
+?>
108 111
         </div>
109 112
       </div>
110 113
     </div>
Please login to merge, or discard this patch.
site/models/ChangeEmailForm.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
     // check that the desired_email is not already the email of another user
49 49
     $user = $this->user->findByEmail($this->desired_email);
50 50
     // if it is, we do nothing and return true, don't leak the data
51
-    if(!$user) {
51
+    if (!$user) {
52 52
       $this->user->desired_email = $this->desired_email;
53 53
       $this->user->generateChangeEmailToken();
54 54
       $this->user->save();
Please login to merge, or discard this patch.
site/models/EditProfileForm.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
       $graph = Yii::$container
82 82
         ->get(\common\components\Graph::class, [$this->user]);
83 83
 
84
-      if($this->timezone)
84
+      if ($this->timezone)
85 85
         $user->timezone = $this->timezone;
86
-      if($this->expose_graph) {
86
+      if ($this->expose_graph) {
87 87
         $user->expose_graph = true;
88 88
 
89 89
         // generate scores graph image
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         // if they haven't done a check-in in the last month this
92 92
         // will explode because $scores_last_month is an empty
93 93
         // array
94
-        if($scores_last_month) {
94
+        if ($scores_last_month) {
95 95
           $graph->create($scores_last_month, true);
96 96
         }
97 97
       } else {
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         // remove scores graph image
100 100
         $graph->destroy();
101 101
       }
102
-      if($this->send_email) {
102
+      if ($this->send_email) {
103 103
         $user->email_threshold = $this->email_threshold;
104 104
         $user->partner_email1  = $this->partner_email1;
105 105
         $user->partner_email2  = $this->partner_email2;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,8 +81,9 @@
 block discarded – undo
81 81
       $graph = Yii::$container
82 82
         ->get(\common\components\Graph::class, [$this->user]);
83 83
 
84
-      if($this->timezone)
85
-        $user->timezone = $this->timezone;
84
+      if($this->timezone) {
85
+              $user->timezone = $this->timezone;
86
+      }
86 87
       if($this->expose_graph) {
87 88
         $user->expose_graph = true;
88 89
 
Please login to merge, or discard this patch.