Skip to content

Instantly share code, notes, and snippets.

@chrisbaswell
Last active May 4, 2021 21:22
Show Gist options
  • Save chrisbaswell/5a0c210011b21169c9ae4591900b5da9 to your computer and use it in GitHub Desktop.
Save chrisbaswell/5a0c210011b21169c9ae4591900b5da9 to your computer and use it in GitHub Desktop.
dd_on
/**
* Die and dump on the Nth time this function is called
*/
if (! function_exists('dd_on')) {
function dd_on(int $number, ...$args): void
{
if (!isset($GLOBALS['dd'])) {
$GLOBALS['dd'] = 0;
}
if ($GLOBALS['dd'] === $number) {
dd(...$args);
}
$GLOBALS['dd']++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment