Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trap options: if(), once(), times(), depth() #29

Merged
merged 9 commits into from
Nov 26, 2023
Prev Previous commit
Next Next commit
Add samples in the readme
roxblnfk committed Nov 26, 2023
commit f8d4c8d91942c5cdf289769790ccebef731c0f92
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -88,6 +88,21 @@ Additionally, you can manually set traps in the code. Use the `trap()` function,
which works almost the same as Symfony's `dump()`, but configures the dumper to send dumps to the local server,
unless other user settings are provided.

Also, the `trap()` has a lot of useful options:

```php
// Limit the depth of the dumped structure
trap($veryDeepArray)->depth(3);

foreach ($veryLargeArray as $item) {
// We don't need to dump more than 3 items
trap($item)->times(3);
}

// Dump only if the condition is true
trap($animal)->once()->if($var instanceof Anumal\Cat);
```

---

We care about the quality of our products' codebase and strive to provide the best user experience.
@@ -108,8 +123,8 @@ Then just call the `trap()` function in your code:

```php
trap(); // dump the current stack trace
trap($var); // dump a variable
trap($var, foo: $far, bar: $bar); // dump a variables sequence
trap($var)->depth(4); // dump a variable with a depth limit
trap($var, foo: $far, bar: $bar); // dump a named variables sequence
```

> **Note**: