Conditions | 8 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 14 |
Lines | 3 |
Ratio | 14.29 % |
Changes | 0 |
1 | <?php |
||
28 | public static function verifySignature($token) |
||
|
|||
29 | { |
||
30 | $signature = $_GET['signature']; |
||
31 | $timestamp = $_GET['timestamp']; |
||
32 | $nonce = $_GET['nonce']; |
||
33 | |||
34 | View Code Duplication | if (!is_string($signature) || !is_numeric($timestamp) || $timestamp <= 0 || !is_string($nonce) || $nonce == '') { |
|
35 | return false; |
||
36 | } |
||
37 | |||
38 | $tmpArr = [$token, $timestamp, $nonce]; |
||
39 | sort($tmpArr, SORT_STRING); |
||
40 | $tmpStr = implode($tmpArr); |
||
41 | $tmpStr = sha1($tmpStr); |
||
42 | |||
43 | if ($tmpStr == $signature && $signature != null) { |
||
44 | return true; |
||
45 | } else { |
||
46 | return false; |
||
47 | } |
||
48 | } |
||
49 | } |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: