From 9e7e644178754d7ab3f1f07fe85918d30583e007 Mon Sep 17 00:00:00 2001 From: Jonathan Goode Date: Tue, 27 Sep 2022 14:25:38 +0100 Subject: [PATCH] Add `pauseIf()` / `pauseUnless()` (#999) * Add `pauseIf()` * Add `pauseUnless()` --- src/Browser.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Browser.php b/src/Browser.php index 51f2420dd..656ce912e 100644 --- a/src/Browser.php +++ b/src/Browser.php @@ -635,6 +635,38 @@ public function pause($milliseconds) return $this; } + /** + * Pause for the given amount of milliseconds if the given condition is true. + * + * @param bool $boolean + * @param int $milliseconds + * @return $this + */ + public function pauseIf($boolean, $milliseconds) + { + if ($boolean) { + return $this->pause($milliseconds); + } + + return $this; + } + + /** + * Pause for the given amount of milliseconds unless the given condition is true. + * + * @param bool $boolean + * @param int $milliseconds + * @return $this + */ + public function pauseUnless($boolean, $milliseconds) + { + if (! $boolean) { + return $this->pause($milliseconds); + } + + return $this; + } + /** * Close the browser. *