Completed
Pull Request — master (#159)
by Corey
03:50
created
console/migrations/m160403_060352_delete_incorrect_behaviors.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,6 +15,6 @@
 block discarded – undo
15 15
         $this->batchInsert("{{%option}}", ["name", "category_id"],[
16 16
             ["masturbation", 3]
17 17
             , ["pornography", 3]
18
-       ]);
18
+        ]);
19 19
     }
20 20
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
     public function safeDown()
14 14
     {
15
-        $this->batchInsert("{{%option}}", ["name", "category_id"],[
15
+        $this->batchInsert("{{%option}}", ["name", "category_id"], [
16 16
             ["masturbation", 3]
17 17
             , ["pornography", 3]
18 18
        ]);
Please login to merge, or discard this patch.
console/migrations/m150407_034100_fix_typo_in_option.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
 
13 13
     public function down()
14 14
     {
15
-		echo "Why even revert this.";
15
+    echo "Why even revert this.";
16 16
     }
17 17
 }
Please login to merge, or discard this patch.
console/migrations/m140609_010314_populate_category_and_options_table.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -120,39 +120,39 @@
 block discarded – undo
120 120
             ["sleeping too much or too little", 6],
121 121
             ["can't cope", 6],
122 122
             ["overwhelmed", 6],
123
-			['crying for "no reason"', 6],
124
-			["can't think", 6],
125
-			["forgetful", 6],
126
-			["pessimistic", 6],
127
-			["helpless", 6],
128
-			["tired", 6],
129
-			["numb", 6],
130
-			["wanting to run", 6],
131
-			["constant cravings for old coping behaviors", 6],
132
-			["thinking of using drugs and alcohol", 6],
133
-			["seeking out old unhealthy people and places", 6],
134
-			["really isolated", 6],
135
-			["people are angry with you", 6],
136
-			["self-abuse", 6],
137
-			["suicidal thoughts", 6],
138
-			["no goals", 6],
139
-			["survival mode", 6],
140
-			["not returning phone calls", 6],
141
-			["missing work", 6],
142
-			["irritability", 6],
143
-			["loss of appetite", 6],
144
-			["returning to the place you swore you would never go again", 7],
145
-			["giving up", 7],
146
-			["giving in", 7],
147
-			["out of control", 7],
148
-			["lost in your addiction", 7],
149
-			["lying to yourself and others", 7],
150
-			["feeling you just can't manage without your coping behavior, at least for now", 7],
151
-			["shame", 7],
152
-			["condemnation", 7],
153
-			["guilt", 7],
154
-			["aloneness", 7]
155
-       ]);
123
+      ['crying for "no reason"', 6],
124
+      ["can't think", 6],
125
+      ["forgetful", 6],
126
+      ["pessimistic", 6],
127
+      ["helpless", 6],
128
+      ["tired", 6],
129
+      ["numb", 6],
130
+      ["wanting to run", 6],
131
+      ["constant cravings for old coping behaviors", 6],
132
+      ["thinking of using drugs and alcohol", 6],
133
+      ["seeking out old unhealthy people and places", 6],
134
+      ["really isolated", 6],
135
+      ["people are angry with you", 6],
136
+      ["self-abuse", 6],
137
+      ["suicidal thoughts", 6],
138
+      ["no goals", 6],
139
+      ["survival mode", 6],
140
+      ["not returning phone calls", 6],
141
+      ["missing work", 6],
142
+      ["irritability", 6],
143
+      ["loss of appetite", 6],
144
+      ["returning to the place you swore you would never go again", 7],
145
+      ["giving up", 7],
146
+      ["giving in", 7],
147
+      ["out of control", 7],
148
+      ["lost in your addiction", 7],
149
+      ["lying to yourself and others", 7],
150
+      ["feeling you just can't manage without your coping behavior, at least for now", 7],
151
+      ["shame", 7],
152
+      ["condemnation", 7],
153
+      ["guilt", 7],
154
+      ["aloneness", 7]
155
+        ]);
156 156
     }
157 157
 
158 158
     public function safeDown()
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
          */
20 20
 
21 21
 
22
-        $this->batchInsert("{{%option}}", ["name", "category_id"],[
22
+        $this->batchInsert("{{%option}}", ["name", "category_id"], [
23 23
             ["no current secrets", 1],
24 24
             ["resolving problems", 1],
25 25
             ["identifying fears and feelings", 1],
Please login to merge, or discard this patch.
common/components/Time.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
   }
32 32
 
33 33
   public function getLocalTime($timezone = null) {
34
-    if($timezone === null)
34
+    if ($timezone === null)
35 35
       $timezone = $this->timezone;
36 36
 
37 37
     $timestamp = new DateTime("now", new DateTimeZone($timezone));
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
   }
40 40
 
41 41
   public function getLocalDate($timezone = null) {
42
-    if($timezone === null)
42
+    if ($timezone === null)
43 43
       $timezone = $this->timezone;
44 44
 
45 45
     return (new DateTime("now", new DateTimeZone($timezone)))
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
   public function getUTCBookends($local) {
55 55
     $local = trim($local);
56
-    if(strpos($local, " ")) {
56
+    if (strpos($local, " ")) {
57 57
       return false;
58 58
     }
59 59
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,16 +31,18 @@
 block discarded – undo
31 31
   }
32 32
 
33 33
   public function getLocalTime($timezone = null) {
34
-    if($timezone === null)
35
-      $timezone = $this->timezone;
34
+    if($timezone === null) {
35
+          $timezone = $this->timezone;
36
+    }
36 37
 
37 38
     $timestamp = new DateTime("now", new DateTimeZone($timezone));
38 39
     return $timestamp->format("Y-m-d H:i:s");
39 40
   }
40 41
 
41 42
   public function getLocalDate($timezone = null) {
42
-    if($timezone === null)
43
-      $timezone = $this->timezone;
43
+    if($timezone === null) {
44
+          $timezone = $this->timezone;
45
+    }
44 46
 
45 47
     return (new DateTime("now", new DateTimeZone($timezone)))
46 48
       ->format("Y-m-d");
Please login to merge, or discard this patch.
common/components/Graph.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
   public function getFilepath() {
26 26
     $path = Yii::getAlias('@graphImgPath');
27 27
     $filename = $this->user->getIdHash() . ".png";
28
-    return $path. '/' . $filename;
28
+    return $path . '/' . $filename;
29 29
   }
30 30
 
31 31
   /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
    * @return string the encoded image
59 59
    */
60 60
   public function create(array $values, bool $save = false) {
61
-    if($save) {
61
+    if ($save) {
62 62
       // wipe out the current image, if it exists
63 63
       $this->destroy();
64 64
     }
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
     imagepng($img);
96 96
     $img_data = ob_get_clean();
97 97
 
98
-    if($save) {
98
+    if ($save) {
99 99
       $filepath = $this->getFilepath(); 
100
-      if(!is_dir(dirname($filepath))) {
100
+      if (!is_dir(dirname($filepath))) {
101 101
         mkdir(dirname($filepath), 0766, true);
102 102
       }
103 103
 
Please login to merge, or discard this patch.
common/components/Utility.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
   public static $REVISION_FILE = "./REVISION";
8 8
 
9 9
   public static function getGithubRevUrl($file = false) {
10
-    if($hash = self::getRevHash($file)) {
10
+    if ($hash = self::getRevHash($file)) {
11 11
       return "https://github.com/CorWatts/fasterscale/commit/$hash";
12 12
     }
13 13
     return false;
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
   public static function getRevHash($file = false) {
17 17
     $file = $file ?: self::$REVISION_FILE;
18
-    if(is_file($file) && is_readable($file)) {
18
+    if (is_file($file) && is_readable($file)) {
19 19
       return substr(file_get_contents($file), 0, 7);
20 20
     }
21 21
     return false;
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
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
       $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior');
34 34
       $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion');
35 35
 
36
-      $this->container->set('common\interfaces\TimeInterface', function () {
36
+      $this->container->set('common\interfaces\TimeInterface', function() {
37 37
         return new \common\components\Time('America/Los_Angeles');
38 38
       });
39 39
       //$this->container->set('common\interfaces\TimeInterface', '\common\components\Time');
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     public function testGetLocalTime()
52 52
     {
53
-      $this->specify('getLocalTime should function correctly', function () {
53
+      $this->specify('getLocalTime should function correctly', function() {
54 54
         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")));
55 55
         expect('getLocalTime should work with a custom timezone', $this->assertEquals($this->time->getLocalTime("UTC"), (new DateTime("now"))->format("Y-m-d H:i:s")));
56 56
       });
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 
59 59
     public function testConvertLocalToUTC()
60 60
     {
61
-      $this->specify('convertLocalToUTC should function correctly', function () {
61
+      $this->specify('convertLocalToUTC should function correctly', function() {
62 62
         $la_tz = (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s");
63 63
 
64 64
         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")));
65 65
         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")));
66 66
         // with UTC
67
-        $this->container->set('common\interfaces\TimeInterface', function () {
67
+        $this->container->set('common\interfaces\TimeInterface', function() {
68 68
           return new \common\components\Time('UTC');
69 69
         });
70 70
         $time = $this->container->get('common\interfaces\TimeInterface');
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 
78 78
     public function testConvertUTCToLocal()
79 79
     {
80
-      $this->specify('convertUTCToLocal should function correctly', function () {
80
+      $this->specify('convertUTCToLocal should function correctly', function() {
81 81
         $utc_tz = (new DateTime("now"))->format("Y-m-d H:i:s");
82 82
 
83 83
         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)));
84 84
         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")));
85 85
 
86 86
         // with UTC
87
-        $this->container->set('common\interfaces\TimeInterface', function () {
87
+        $this->container->set('common\interfaces\TimeInterface', function() {
88 88
           return new \common\components\Time('UTC');
89 89
         });
90 90
         $time = $this->container->get('common\interfaces\TimeInterface');
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
     public function testGetLocalDate()
99 99
     {
100
-      $this->specify('getLocalDate should function correctly', function () {
100
+      $this->specify('getLocalDate should function correctly', function() {
101 101
         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")));
102 102
         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")));
103 103
       });
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         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 ')));
120 120
         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']));
121 121
         // with UTC
122
-        $this->container->set('common\interfaces\TimeInterface', function () {
122
+        $this->container->set('common\interfaces\TimeInterface', function() {
123 123
           return new \common\components\Time('UTC');
124 124
         });
125 125
         $time = $this->container->get('common\interfaces\TimeInterface');
Please login to merge, or discard this patch.
common/tests/unit/components/UtilityTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
   protected function tearDown()
23 23
   {
24 24
     // just in case we're forgetful :)
25
-    if(file_exists(Utility::$REVISION_FILE)) $this->_deleteRevFile();
25
+    if (file_exists(Utility::$REVISION_FILE)) $this->_deleteRevFile();
26 26
     parent::tearDown();
27 27
   }
28 28
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
   public function testGetRevHash()
39 39
   {
40
-    $this->specify('getRevHash should function correctly', function () {
40
+    $this->specify('getRevHash should function correctly', function() {
41 41
       expect('getRevHash should return false when the file does not exist', $this->assertFalse(Utility::getRevHash()));
42 42
 
43 43
       $this->_createRevFile();
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
   protected function tearDown()
23 23
   {
24 24
     // just in case we're forgetful :)
25
-    if(file_exists(Utility::$REVISION_FILE)) $this->_deleteRevFile();
25
+    if(file_exists(Utility::$REVISION_FILE)) {
26
+      $this->_deleteRevFile();
27
+    }
26 28
     parent::tearDown();
27 29
   }
28 30
 
Please login to merge, or discard this patch.
common/tests/unit/components/GraphTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
   use \Codeception\Specify;
15 15
 
16 16
   private $user;
17
-  private $filepath = __DIR__.'/../../_output/test_graph.png';
18
-  private $filepath_extra = __DIR__.'/../../_output/charts/test_graph.png';
17
+  private $filepath = __DIR__ . '/../../_output/test_graph.png';
18
+  private $filepath_extra = __DIR__ . '/../../_output/charts/test_graph.png';
19 19
 
20 20
   public function setUp() {
21 21
     $this->user = $this->getMockBuilder('\site\tests\_support\MockUser')
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
       ->willReturn('random1DH4sh');
37 37
     $graph = new Graph($this->user);
38 38
 
39
-    expect('the expected graph image filepath will be returned', $this->assertEquals(dirname(dirname(dirname(dirname(__DIR__)))).'/site/web/charts/random1DH4sh.png', $graph->getFilepath()));
39
+    expect('the expected graph image filepath will be returned', $this->assertEquals(dirname(dirname(dirname(dirname(__DIR__)))) . '/site/web/charts/random1DH4sh.png', $graph->getFilepath()));
40 40
   }
41 41
 
42 42
   public function testGetUrl() {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
       ->method('getFilepath')
65 65
       ->willReturn($this->filepath);
66 66
 
67
-    if(!file_exists($this->filepath) && preg_match('%/_output/test_graph.png$%', $this->filepath)) {
67
+    if (!file_exists($this->filepath) && preg_match('%/_output/test_graph.png$%', $this->filepath)) {
68 68
       touch($this->filepath);
69 69
       expect('just a check to be sure $filepath is sane', $this->assertStringEndsWith('/_output/test_graph.png', $this->filepath));
70 70
       expect('the generated file should exist', $this->assertFileExists($this->filepath));
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     expect('the generated file should be readable', $this->assertFileExists($this->filepath_extra));
104 104
 
105 105
     // cleanup
106
-    if(file_exists($this->filepath_extra) && preg_match('%/_output/charts/test_graph.png%', $this->filepath_extra)) {
106
+    if (file_exists($this->filepath_extra) && preg_match('%/_output/charts/test_graph.png%', $this->filepath_extra)) {
107 107
       // just in case something is weird, we don't want to straight rm this file
108 108
       unlink($this->filepath_extra);
109 109
       rmdir(dirname($this->filepath_extra));
Please login to merge, or discard this patch.