Completed
Pull Request — master (#160)
by Corey
03:42
created
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');
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');
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')
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')->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');
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.
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.