| Conditions | 5 | 
| Paths | 2 | 
| Total Lines | 15 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 7 | 
| CRAP Score | 5 | 
| Changes | 0 | ||
| 1 | <?php | ||
| 22 | 3 | public static function verify( | |
| 23 | $payload, | ||
| 24 | $header, | ||
| 25 | $secret, | ||
| 26 | $tolerance = self::DEFAULT_TOLERANCE | ||
| 27 |     ) { | ||
| 28 | 3 |         list($timestamp, $signature) = explode(':', trim($header), 2); | |
| 29 | |||
| 30 | 3 | if (!is_numeric($timestamp) || empty($signature) || | |
| 31 | 3 |                 (($tolerance > 0) && (abs(time() - $timestamp) > $tolerance))) { | |
| 32 | 2 | return false; | |
| 33 | } | ||
| 34 | 1 |         $expected = hash_hmac('sha256', "{$timestamp}:{$payload}", $secret); | |
| 35 | 1 | return hash_equals($expected, $signature); | |
| 36 | } | ||
| 37 | } | ||
| 38 |