Skip to content

Commit 9e7e644

Browse files
authored
Add pauseIf() / pauseUnless() (#999)
* Add `pauseIf()` * Add `pauseUnless()`
1 parent 5969741 commit 9e7e644

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Browser.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,38 @@ public function pause($milliseconds)
635635
return $this;
636636
}
637637

638+
/**
639+
* Pause for the given amount of milliseconds if the given condition is true.
640+
*
641+
* @param bool $boolean
642+
* @param int $milliseconds
643+
* @return $this
644+
*/
645+
public function pauseIf($boolean, $milliseconds)
646+
{
647+
if ($boolean) {
648+
return $this->pause($milliseconds);
649+
}
650+
651+
return $this;
652+
}
653+
654+
/**
655+
* Pause for the given amount of milliseconds unless the given condition is true.
656+
*
657+
* @param bool $boolean
658+
* @param int $milliseconds
659+
* @return $this
660+
*/
661+
public function pauseUnless($boolean, $milliseconds)
662+
{
663+
if (! $boolean) {
664+
return $this->pause($milliseconds);
665+
}
666+
667+
return $this;
668+
}
669+
638670
/**
639671
* Close the browser.
640672
*

0 commit comments

Comments
 (0)