Skip to content

Commit c6d6485

Browse files
committed
Libs(PHP): extract helper fn is_postitive_integer
Motivated by superlinter complaining about how long a line was.
1 parent 0f93c9a commit c6d6485

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

php/src/Webhook.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ public function verify($payload, $headers)
7070

7171
public function sign($msgId, $timestamp, $payload)
7272
{
73-
$is_positive_integer = is_numeric($timestamp) && !is_float($timestamp + 0) && (int) $timestamp == $timestamp && (int) $timestamp > 0;
74-
if (!$is_positive_integer) {
73+
if (!self::isPositiveInteger($timestamp)) {
7574
throw new Exception\WebhookSigningException("Invalid timestamp");
7675
}
7776
$toSign = "{$msgId}.{$timestamp}.{$payload}";
@@ -97,4 +96,9 @@ private function verifyTimestamp($timestampHeader)
9796
}
9897
return $timestamp;
9998
}
99+
100+
private function isPositiveInteger($v)
101+
{
102+
return is_numeric($v) && !is_float($v + 0) && (int) $v == $v && (int) $v > 0;
103+
}
100104
}

0 commit comments

Comments
 (0)