diff --git a/src/Client/TrapHandle.php b/src/Client/TrapHandle.php index bf3831b2..1fb9bcae 100644 --- a/src/Client/TrapHandle.php +++ b/src/Client/TrapHandle.php @@ -23,6 +23,19 @@ public static function fromArray(array $array): self return $new; } + /** + * Dump only if the condition is true. + */ + public function if(bool|callable $condition): self + { + if (\is_callable($condition)) { + $condition = $condition(); + } + + $this->haveToSend = $condition; + return $this; + } + public function __destruct() { $this->haveToSend and $this->sendUsingDump();