@@ -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 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function testRemoveVar() { |
| 234 | 234 | $this->doTest(function(CryptTool $cryptTool, $prefix) { |
| 235 | - foreach(array( |
|
| 235 | + foreach (array( |
|
| 236 | 236 | 'hex' => Constants::myPrivateKeyExtract, |
| 237 | 237 | 'bin' => $cryptTool->hex2bin(Constants::myPrivateKeyExtract) |
| 238 | 238 | ) as $key => $testVar) { |
@@ -246,12 +246,12 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | private function doTest(\Closure $c) { |
| 249 | - foreach(array( |
|
| 249 | + foreach (array( |
|
| 250 | 250 | 'Salt' => CryptTool::createInstance(CryptTool::TYPE_SALT), |
| 251 | 251 | 'Sodium' => CryptTool::createInstance(CryptTool::TYPE_SODIUM) |
| 252 | 252 | ) as $key => $instance) { |
| 253 | 253 | |
| 254 | - if($instance === null) { |
|
| 254 | + if ($instance === null) { |
|
| 255 | 255 | echo $key.": could not instance crypt tool\n"; |
| 256 | 256 | break; |
| 257 | 257 | } |