@@ -59,7 +59,7 @@ |
||
59 | 59 | * @param object $res |
60 | 60 | * @return SendSimpleResult |
61 | 61 | */ |
62 | - public function parseResult($httpCode, $res){ |
|
62 | + public function parseResult($httpCode, $res) { |
|
63 | 63 | return new SendSimpleResult($httpCode, $res); |
64 | 64 | } |
65 | 65 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | * @param object $res |
44 | 44 | * @return UploadFileResult |
45 | 45 | */ |
46 | - public function parseResult($httpCode, $res){ |
|
46 | + public function parseResult($httpCode, $res) { |
|
47 | 47 | return new DownloadFileResult($httpCode, $res); |
48 | 48 | } |
49 | 49 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param object $res |
43 | 43 | * @return FetchPublicKeyResult |
44 | 44 | */ |
45 | - public function parseResult($httpCode, $res){ |
|
45 | + public function parseResult($httpCode, $res) { |
|
46 | 46 | return new FetchPublicKeyResult($httpCode, $res); |
47 | 47 | } |
48 | 48 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * @param object $res |
50 | 50 | * @return UploadFileResult |
51 | 51 | */ |
52 | - public function parseResult($httpCode, $res){ |
|
52 | + public function parseResult($httpCode, $res) { |
|
53 | 53 | return new UploadFileResult($httpCode, $res); |
54 | 54 | } |
55 | 55 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | * @param object $res |
40 | 40 | * @return CapabilityResult |
41 | 41 | */ |
42 | - public function parseResult($httpCode, $res){ |
|
42 | + public function parseResult($httpCode, $res) { |
|
43 | 43 | return new CapabilityResult($httpCode, $res); |
44 | 44 | } |
45 | 45 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * @param object $res |
28 | 28 | * @return CreditsResult |
29 | 29 | */ |
30 | - public function parseResult($httpCode, $res){ |
|
30 | + public function parseResult($httpCode, $res) { |
|
31 | 31 | return new CreditsResult($httpCode, $res); |
32 | 32 | } |
33 | 33 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | * @param object $res |
77 | 77 | * @return SendE2EResult |
78 | 78 | */ |
79 | - public function parseResult($httpCode, $res){ |
|
79 | + public function parseResult($httpCode, $res) { |
|
80 | 80 | return new SendE2EResult($httpCode, $res); |
81 | 81 | } |
82 | 82 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $this->assertNotNull($message); |
58 | 58 | $this->assertTrue($message instanceof TextMessage); |
59 | - if($message instanceof TextMessage) { |
|
59 | + if ($message instanceof TextMessage) { |
|
60 | 60 | $this->assertEquals($message->getText(), 'Dies ist eine Testnachricht. äöü'); |
61 | 61 | } |
62 | 62 | }); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | |
94 | 94 | public function testDerivePublicKey() { |
95 | - $this->doTest(function(CryptTool $cryptTool, $prefix){ |
|
95 | + $this->doTest(function(CryptTool $cryptTool, $prefix) { |
|
96 | 96 | $publicKey = $cryptTool->derivePublicKey($cryptTool->hex2bin(Common::getPrivateKey(Constants::myPrivateKey))); |
97 | 97 | $myPublicKey = $cryptTool->hex2bin(Common::getPublicKey(Constants::myPublicKey)); |
98 | 98 | |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | $timeElapsed = []; |
168 | 168 | $comparisonResult = []; |
169 | 169 | $timeElapsedAvg = []; |
170 | - foreach(array( |
|
171 | - 'length' => [$string1, $string1 . 'a'], |
|
170 | + foreach (array( |
|
171 | + 'length' => [$string1, $string1.'a'], |
|
172 | 172 | 'diff' => [$string1, $string2], |
173 | 173 | 'same' => [$string1, $string1] |
174 | 174 | ) as $testName => $strings) { |
175 | 175 | $timeMin = [null, 0]; |
176 | 176 | $timeMax = [null, 0]; |
177 | - for ($i=0; $i < 3; $i++) { |
|
177 | + for ($i = 0; $i < 3; $i++) { |
|
178 | 178 | // test run with delay |
179 | 179 | $timeElapsed[$testName][$i] = -microtime(true); |
180 | 180 | $comparisonResult[$testName][$i] = $cryptTool->stringCompare($strings[0], $strings[1]); |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | array_splice($timeElapsed[$testName], $timeMax[1] >= $timeMin[1] ? ($timeMax[1]-1) : $timeMax[1], 1); |
208 | 208 | |
209 | 209 | // calculate average (currently useless as there is only one value left, but it may be useful later) |
210 | - $timeElapsedAvg[$testName] = array_sum($timeElapsed[$testName]) / count($timeElapsed[$testName]); |
|
210 | + $timeElapsedAvg[$testName] = array_sum($timeElapsed[$testName])/count($timeElapsed[$testName]); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | // check timings |
214 | 214 | echo 'Timing test results with '.$prefix.':'.PHP_EOL; |
215 | - $timingRatio = $timeElapsedAvg['diff'] / $timeElapsedAvg['same']; |
|
216 | - $absoluteDifference = abs($timeElapsedAvg['diff'] - $timeElapsedAvg['same']); |
|
215 | + $timingRatio = $timeElapsedAvg['diff']/$timeElapsedAvg['same']; |
|
216 | + $absoluteDifference = abs($timeElapsedAvg['diff']-$timeElapsedAvg['same']); |
|
217 | 217 | echo 'timing ratio: '.$timingRatio.PHP_EOL; |
218 | 218 | echo 'absolute difference: '.$absoluteDifference.PHP_EOL; |
219 | 219 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $allowedDifferenceLow = 0.25; |
222 | 222 | $allowedDifferenceTop = 0.5; |
223 | 223 | // double value if running in a CI envoriment |
224 | - if (getenv('CI') == 'true') { |
|
224 | + if (getenv('CI') == 'true') { |
|
225 | 225 | $allowedDifferenceLow = $allowedDifferenceLow*2; |
226 | 226 | $allowedDifferenceTop = $allowedDifferenceTop*2; |
227 | 227 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function testRemoveVar() { |
241 | 241 | $this->doTest(function(CryptTool $cryptTool, $prefix) { |
242 | - foreach(array( |
|
242 | + foreach (array( |
|
243 | 243 | 'hex' => Constants::myPrivateKeyExtract, |
244 | 244 | 'bin' => $cryptTool->hex2bin(Constants::myPrivateKeyExtract) |
245 | 245 | ) as $key => $testVar) { |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | private function doTest(\Closure $c) { |
256 | - foreach(array( |
|
256 | + foreach (array( |
|
257 | 257 | 'Salt' => CryptTool::createInstance(CryptTool::TYPE_SALT), |
258 | 258 | 'Sodium' => CryptTool::createInstance(CryptTool::TYPE_SODIUM) |
259 | 259 | ) as $key => $instance) { |
260 | 260 | |
261 | - if($instance === null) { |
|
261 | + if ($instance === null) { |
|
262 | 262 | echo $key.": could not instance crypt tool\n"; |
263 | 263 | break; |
264 | 264 | } |
@@ -2,8 +2,8 @@ |
||
2 | 2 | <?php |
3 | 3 | // set variables |
4 | 4 | $dir = dirname(__DIR__); |
5 | -$source = dirname(__DIR__) . '/source'; |
|
6 | -$file = $dir . '/threema_msgapi.phar'; |
|
5 | +$source = dirname(__DIR__).'/source'; |
|
6 | +$file = $dir.'/threema_msgapi.phar'; |
|
7 | 7 | |
8 | 8 | // preparation |
9 | 9 | if (!is_dir($dir)) { |