From fae8ff885c6a65cca7bccb982e98e3c25e10890c Mon Sep 17 00:00:00 2001 From: peterbakker Date: Thu, 19 Mar 2020 20:01:45 +0100 Subject: [PATCH] Only sleep if there is work to do --- src/Client.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Client.php b/src/Client.php index 55bfb3b..378c5e7 100644 --- a/src/Client.php +++ b/src/Client.php @@ -296,7 +296,9 @@ class Client $this->signPayloadKid(null, $challenge->getAuthorizationURL()) ); $data = json_decode((string)$response->getBody(), true); - sleep(ceil(15 / $maxAttempts)); + if ($maxAttempts > 1) { + sleep(ceil(15 / $maxAttempts)); + } $maxAttempts--; } while ($maxAttempts > 0 && $data['status'] != 'valid'); @@ -441,7 +443,9 @@ class Client } } } - sleep(ceil(45 / $maxAttempts)); + if ($maxAttempts > 1) { + sleep(ceil(45 / $maxAttempts)); + } $maxAttempts--; } while ($maxAttempts > 0);