Skip to content

Commit 551e950

Browse files
committed
The Collector is formatted in JSON format
1 parent 7462172 commit 551e950

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/Collectors/Collector.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ public function getName(): string
3333

3434
protected function applyPipeCollect()
3535
{
36-
$pipedCollect = collect($this->collect())
37-
->when($this->pipe, function (Collection $collects) {
38-
return $collects->pipe($this->pipe);
39-
});
40-
41-
return collect($pipedCollect)
36+
return collect($this->collect())
37+
->when($this->pipe, function (Collection $collects) {
38+
return collect($collects->pipe($this->pipe));
39+
})
4240
->filter(function ($item) {
4341
return ! blank($item);
4442
})
@@ -47,6 +45,9 @@ protected function applyPipeCollect()
4745

4846
public function __toString()
4947
{
50-
return (string) var_output($this->applyPipeCollect(), true);
48+
return (string) json_encode(
49+
$this->applyPipeCollect(),
50+
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT
51+
);
5152
}
5253
}

src/Collectors/ExceptionTraceCollector.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,16 @@ public function __construct(callable $pipe = null)
2424
parent::__construct();
2525
$this->pipe = $pipe
2626
?: function (Collection $traces) {
27-
return $traces->filter(function ($trace) {
28-
return ! Str::contains($trace, 'vendor');
29-
});
27+
return $traces
28+
->filter(function ($trace) {
29+
return ! Str::contains($trace, 'vendor');
30+
})
31+
->values();
3032
};
3133
}
3234

3335
public function collect()
3436
{
35-
return collect(explode("\n", $this->exception->getTraceAsString()))
36-
->transform(function ($trace, $index) {
37-
return ltrim($trace, "#$index ");
38-
})
39-
->all();
37+
return explode("\n", $this->exception->getTraceAsString());
4038
}
4139
}

0 commit comments

Comments
 (0)