@@ -15,6 +15,6 @@ |
||
15 | 15 | $this->batchInsert("{{%option}}", ["name", "category_id"],[ |
16 | 16 | ["masturbation", 3] |
17 | 17 | , ["pornography", 3] |
18 | - ]); |
|
18 | + ]); |
|
19 | 19 | } |
20 | 20 | } |
@@ -12,7 +12,7 @@ |
||
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 | ]); |
@@ -12,6 +12,6 @@ |
||
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 | } |
@@ -120,39 +120,39 @@ |
||
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() |
@@ -19,7 +19,7 @@ |
||
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], |
@@ -31,16 +31,18 @@ |
||
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"); |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @return \DateTime the parsed time or the default value |
37 | 37 | */ |
38 | 38 | public function parse($time, $default = false, string $format = 'Y-m-d') { |
39 | - if(is_string($time)) { |
|
39 | + if (is_string($time)) { |
|
40 | 40 | $dt = DateTime::createFromFormat($format, $time, new DateTimeZone($this->timezone)); |
41 | - if($dt) { |
|
41 | + if ($dt) { |
|
42 | 42 | // for some reason, using createFromFromat adds in the time. The regular DateTime constructor _does not_ do this. We manually zero out the time here to make the DateTime objects match. |
43 | 43 | $dt->setTime(0, 0, 0); |
44 | 44 | $formatted = $dt->format($format); |
45 | - if($formatted === $time && $this->inBounds($dt)) { |
|
45 | + if ($formatted === $time && $this->inBounds($dt)) { |
|
46 | 46 | return $dt; |
47 | 47 | } |
48 | 48 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $test = strtotime($dt->format('Y-m-d')); |
63 | 63 | $now = strtotime($this->getLocalDate()); |
64 | 64 | |
65 | - if($first <= $test && $test <= $now) { |
|
65 | + if ($first <= $test && $test <= $now) { |
|
66 | 66 | return true; |
67 | 67 | } else { |
68 | 68 | return false; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | public function getLocalTime($timezone = null) { |
89 | - if($timezone === null) |
|
89 | + if ($timezone === null) |
|
90 | 90 | $timezone = $this->timezone; |
91 | 91 | |
92 | 92 | $timestamp = new DateTime("now", new DateTimeZone($timezone)); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | public function getLocalDate($timezone = null) { |
97 | - if($timezone === null) |
|
97 | + if ($timezone === null) |
|
98 | 98 | $timezone = $this->timezone; |
99 | 99 | |
100 | 100 | return (new DateTime("now", new DateTimeZone($timezone))) |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | public function getUTCBookends($local) { |
110 | 110 | $local = trim($local); |
111 | - if(strpos($local, " ")) { |
|
111 | + if (strpos($local, " ")) { |
|
112 | 112 | return false; |
113 | 113 | } |
114 | 114 | |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @return string a date string |
131 | 131 | */ |
132 | 132 | public function validate($date = null) { |
133 | - if(is_null($date)) { |
|
133 | + if (is_null($date)) { |
|
134 | 134 | return $this->getLocalDate(); |
135 | - } else if($dt = $this->parse($date)) { |
|
135 | + } else if ($dt = $this->parse($date)) { |
|
136 | 136 | return $dt->format('Y-m-d'); |
137 | 137 | } else { |
138 | 138 | return $this->getLocalDate(); |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | public function getDateTimesInPeriod(int $period = 30) { |
150 | 150 | $dt = new DateTime("now", new DateTimeZone("UTC")); |
151 | 151 | $dt2 = new DateTime("now", new DateTimeZone("UTC")); |
152 | - $end = $dt->add(new \DateInterval('PT2M')); // to be sure we have everything |
|
152 | + $end = $dt->add(new \DateInterval('PT2M')); // to be sure we have everything |
|
153 | 153 | $start = $dt2->add(new \DateInterval('PT2M')); // to be sure we have everything |
154 | 154 | $start = $start->sub(new \DateInterval("P${period}D")); |
155 | 155 | $periods = new \DatePeriod($start, new \DateInterval('P1D'), $end); |
156 | 156 | $local_tz = new \DateTimeZone($this->timezone); |
157 | - foreach($periods as $period) { |
|
157 | + foreach ($periods as $period) { |
|
158 | 158 | $period->setTimezone($local_tz); |
159 | 159 | } |
160 | 160 | return $periods; |
@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -7,7 +7,7 @@ discard block |
||
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 |
||
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; |
@@ -22,7 +22,7 @@ discard block |
||
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 |
||
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(); |
@@ -22,7 +22,9 @@ |
||
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 |
@@ -14,8 +14,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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)); |
@@ -31,7 +31,7 @@ |
||
31 | 31 | ->getMock(); |
32 | 32 | |
33 | 33 | $mocks = \yii\helpers\ArrayHelper::merge($defaultMocks, $mocks); |
34 | - foreach($mocks as $name => $val) { |
|
34 | + foreach ($mocks as $name => $val) { |
|
35 | 35 | $user->method($name)->willReturn($val); |
36 | 36 | } |
37 | 37 | $user->method('findByEmail')->will($this->returnSelf()); |