Passed
Pull Request — master (#163)
by Corey
03:22
created
site/controllers/CheckinController.php 1 patch
Spacing   +6 added lines, -6 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
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     $date = Yii::$container->get(\common\interfaces\TimeInterface::class)->getLocalDate();
66 66
 
67 67
     $user_behaviors = $user_behavior->getUserBehaviorsWithCategory($date);
68
-    if(count($user_behaviors) === 0) {
68
+    if (count($user_behaviors) === 0) {
69 69
       return $this->redirect(['view']);
70 70
     }
71 71
 
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
       $form->deleteToday();
76 76
 
77 77
       $behaviors = $user_behavior->findAll($form->getUserBehaviorIds());
78
-      if($result = $form->saveAnswers($behaviors)) {
78
+      if ($result = $form->saveAnswers($behaviors)) {
79 79
 
80
-        if(Yii::$app->user->identity->send_email) {
80
+        if (Yii::$app->user->identity->send_email) {
81 81
           Yii::$app->user->identity->sendEmailReport($date);
82 82
           Yii::$app->session->setFlash('success', 'Your check-in is complete. A notification has been sent to your report partners.');
83 83
         } else {
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
   public function actionView(string $date = null)
98 98
   {
99 99
     $time = Yii::$container->get(\common\interfaces\TimeInterface::class);
100
-    if(is_null($date)) {
100
+    if (is_null($date)) {
101 101
       $date = $time->getLocalDate();
102
-    } else if($dt = $time->parse($date)) {
102
+    } else if ($dt = $time->parse($date)) {
103 103
       $date = $dt->format('Y-m-d');
104 104
     } else {
105 105
       $date = $time->getLocalDate();
Please login to merge, or discard this patch.
site/tests/unit/models/SignupFormTest.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
       expect('the form should validate correctly', $this->assertTrue($form->validate()));
137 137
       $user = $form->signup();
138 138
       expect('signup() should return a newly-saved user when the user does not already exist with the submitted values',
139
-             $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 1)));
139
+              $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 1)));
140 140
       expect('the "Remember Me" auth_key value should be set to a random string (defaults to a 32 char length)',
141
-             $this->assertEquals(32, strlen($user->auth_key)));
141
+              $this->assertEquals(32, strlen($user->auth_key)));
142 142
       expect('password_hash to be set to something like a hash',
143
-             $this->assertStringStartsWith('$2y$13$', $user->password_hash));
143
+              $this->assertStringStartsWith('$2y$13$', $user->password_hash));
144 144
       expect('when the user is created, signup() should call save()',
145
-             $this->assertTrue($saved));
145
+              $this->assertTrue($saved));
146 146
       expect('This user should be an isNewRecord -- they should NOT already exist', $this->assertTrue($user->getIsNewRecord()));
147 147
     });
148 148
   }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
       $user = $form3->signup();
187 187
       expect('This user should not be an isNewRecord -- they should already exist', $this->assertFalse($user->getIsNewRecord()));
188 188
       expect('signup() should return a newly-saved user when the user does not already exist with the submitted values',
189
-             $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 1)));
189
+              $this->assertEquals($user->getAttributes($this->whitelist), array_splice($this->vals, 1)));
190 190
       expect('when the user exists and is NOT confirmed, signup() should call save() to UPDATE their info', $this->assertTrue($saved));
191 191
     });
192 192
   }
Please login to merge, or discard this patch.
site/views/site/signup.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 				'id' => 'form-signup',
26 26
 				'enableClientValidation' => true,
27 27
         'enableAjaxValidation' => false,
28
-        'options' => [ 'validateOnSubmit' => true ]
28
+        'options' => ['validateOnSubmit' => true]
29 29
 			]); ?>
30 30
         <?= $form->field($model, 'email', ['inputTemplate' => '<div class="input-group"><span class="input-group-addon">@</span>{input}</div>'])->input('email') ?>
31 31
         <?= $form->field($model, 'password', ['inputTemplate' => '<div class="input-group">{input}<span class="input-group-btn"><button id="password-toggle" class="btn btn-default" type="button">Show</button></span></div>'])->passwordInput() ?>
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
           'template' => '<div class="row"><div class="col-md-5">{image}</div><div class="col-md-6 col-md-offset-1">{input}</div></div>',
35 35
         ]) ?>
36 36
         <?= $form->field($model, 'send_email')->checkbox(['disabled'=>true]) ?>
37
-        <div id='send_email_fields' <?php if(!$model->send_email) { ?>style="display: none;"<?php } ?>>
37
+        <div id='send_email_fields' <?php if (!$model->send_email) { ?>style="display: none;"<?php } ?>>
38 38
           <?= $form->field($model, 'partner_email1')->input('email') ?>
39 39
           <?= $form->field($model, 'partner_email2')->input('email') ?>
40 40
           <?= $form->field($model, 'partner_email3')->input('email') ?>
Please login to merge, or discard this patch.
site/views/checkin/view.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 $plus_week  = $time->alterLocalDate($actual_date, "+1 week");
28 28
 
29 29
 $pie_data = [];
30
-if($answer_pie) {
30
+if ($answer_pie) {
31 31
   $values     = array_map('intval', array_column($answer_pie, "count"));
32 32
   $labels     = array_column($answer_pie, "name");
33 33
   $colors     = array_column($answer_pie, "color");
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
     </div>
69 69
   </div>
70 70
 
71
-  <?php if($questions) {
72
-  foreach($questions as $behavior_id => $behavior_questions) {
71
+  <?php if ($questions) {
72
+  foreach ($questions as $behavior_id => $behavior_questions) {
73 73
     print "<div class='well well-sm'>";
74 74
     print "<button type='button' class='btn btn-primary' disabled='disabled'>{$behavior_questions['question']['title']}</button>";
75 75
     print "<div class='row'>";
76
-    foreach($behavior_questions['answers'] as $question) { 
76
+    foreach ($behavior_questions['answers'] as $question) { 
77 77
       print "<div class='col-md-4'>";
78 78
       print "<p><strong>{$question['title']}</strong></p>";
79
-      print "<p>".Html::encode($question['answer'])."</p>";
79
+      print "<p>" . Html::encode($question['answer']) . "</p>";
80 80
       print "</div>";
81 81
     }
82 82
     print "</div></div>";
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     'options' => ['class' => 'form-horizontal'],
89 89
   ]);
90 90
 
91
-  foreach($categories as $category) {
91
+  foreach ($categories as $category) {
92 92
     $behaviors = AH::map($behaviorsList[$category['id']], 'id', 'name');
93 93
     print $form
94 94
             ->field($model, "behaviors{$category['id']}")
Please login to merge, or discard this patch.
site/views/profile/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
           <?= $form->field($profile, 'email', ['inputTemplate' => '<div class="input-group"><span class="input-group-addon">@</span>{input}</div>']); ?>
26 26
           <?= $form->field($profile, 'timezone')->dropDownList(array_combine($timezones, $timezones)); ?>
27 27
           <?= $form->field($profile, 'send_email')->checkbox() ?>
28
-          <div id='send_email_fields' <?php if(!$profile->send_email) { ?>style="display: none;"<?php } ?>>
28
+          <div id='send_email_fields' <?php if (!$profile->send_email) { ?>style="display: none;"<?php } ?>>
29 29
             <?= $form->field($profile, 'partner_email1')->input('email'); ?>
30 30
             <?= $form->field($profile, 'partner_email2')->input('email'); ?>
31 31
             <?= $form->field($profile, 'partner_email3')->input('email'); ?>
Please login to merge, or discard this patch.
site/models/EditProfileForm.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
       ['email', 'filter', 'filter' => 'trim'],
42 42
       ['email', 'filter', 'filter' => 'strtolower'],
43 43
       ['email', 'email'],
44
-      ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.', 'filter' => "id <> ".Yii::$app->user->id],
44
+      ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.', 'filter' => "id <> " . Yii::$app->user->id],
45 45
 
46 46
       ['timezone', 'string', 'min' => 2, 'max' => 255],
47 47
       ['timezone', 'in', 'range'=>DateTimeZone::listIdentifiers()],
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
   public function saveProfile()
76 76
   {
77 77
     if ($this->validate()) {
78
-      $user  = $this->user;
78
+      $user = $this->user;
79 79
 
80
-      if($this->email)
80
+      if ($this->email)
81 81
         $user->email = $this->email;
82
-      if($this->timezone)
82
+      if ($this->timezone)
83 83
         $user->timezone = $this->timezone;
84
-      if($this->expose_graph) {
84
+      if ($this->expose_graph) {
85 85
         $user->expose_graph = true;
86 86
       } else {
87 87
         $user->expose_graph = false;
88 88
       }
89
-      if($this->send_email) {
89
+      if ($this->send_email) {
90 90
         $user->partner_email1  = $this->partner_email1;
91 91
         $user->partner_email2  = $this->partner_email2;
92 92
         $user->partner_email3  = $this->partner_email3;
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -77,10 +77,12 @@
 block discarded – undo
77 77
     if ($this->validate()) {
78 78
       $user  = $this->user;
79 79
 
80
-      if($this->email)
81
-        $user->email = $this->email;
82
-      if($this->timezone)
83
-        $user->timezone = $this->timezone;
80
+      if($this->email) {
81
+              $user->email = $this->email;
82
+      }
83
+      if($this->timezone) {
84
+              $user->timezone = $this->timezone;
85
+      }
84 86
       if($this->expose_graph) {
85 87
         $user->expose_graph = true;
86 88
       } else {
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
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
    */
83 83
   public function signup() {
84 84
     $user = $this->user->findByEmail($this->email);
85
-    if(!$user) {
85
+    if (!$user) {
86 86
       // this is a brand new user
87 87
       $this->user = $this->setFields($this->user);
88 88
       $this->user->save();
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
        * this is a user that for whatever reason is trying to sign up again
97 97
        * with the same email address.
98 98
        */
99
-      if(!$user->isTokenConfirmed()) {
99
+      if (!$user->isTokenConfirmed()) {
100 100
         /*
101 101
          * they've never verified their account. We don't care if their
102 102
          * verification token is current or expired. We're resetting their
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
       $user->generateAuthKey();
125 125
       $user->generateVerifyEmailToken();
126 126
 
127
-      if($user->send_email) {
127
+      if ($user->send_email) {
128 128
         $user->partner_email1  = $this->partner_email1;
129 129
         $user->partner_email2  = $this->partner_email2;
130 130
         $user->partner_email3  = $this->partner_email3;
Please login to merge, or discard this patch.
common/tests/unit/models/UserBehaviorTest.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -89,19 +89,19 @@
 block discarded – undo
89 89
     expect('decorate should add Behavior data and Category data to an array of UserBehaviors',
90 90
       $this->assertEquals(
91 91
         $this->user_behavior->decorateWithCategory($this->singleSimpleBehaviorNoBehavior),
92
-         [['id' => 396,
93
-           'user_id' => 2,
94
-           'behavior_id' => 107,
95
-           'date' => '2016-06-17 04:12:43',
96
-           'behavior' => [
97
-             'id' => 107,
98
-             'name' => 'numb',
99
-             'category_id' => 6,
100
-             'category' => [
101
-               'id' => 6,
102
-               'name' => 'Exhausted',
103
-             ]
104
-           ]]]));
92
+          [['id' => 396,
93
+            'user_id' => 2,
94
+            'behavior_id' => 107,
95
+            'date' => '2016-06-17 04:12:43',
96
+            'behavior' => [
97
+              'id' => 107,
98
+              'name' => 'numb',
99
+              'category_id' => 6,
100
+              'category' => [
101
+                'id' => 6,
102
+                'name' => 'Exhausted',
103
+              ]
104
+            ]]]));
105 105
   }
106 106
 
107 107
   public function testGetTopBehaviors() {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 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
 
Please login to merge, or discard this patch.
common/tests/unit/models/BehaviorTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 
21 21
     expect('getCategories should return an array of 7 categories', $this->assertEquals(count($behaviors), 7));
22 22
 
23
-    foreach($behaviors as $behavior) {
23
+    foreach ($behaviors as $behavior) {
24 24
       expect('this behavior to have a "name" key', $this->assertArrayHasKey('name', $behavior));
25 25
       expect('this behavior to have a "behavior_count" key', $this->assertArrayHasKey('behavior_count', $behavior));
26 26
       expect('this behavior to have a "category_id" key', $this->assertArrayHasKey('category_id', $behavior));
Please login to merge, or discard this patch.