Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit e62874a

Browse files
committed
Update filters.php - add filters: filter, classPath, props
1 parent 97b801e commit e62874a

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

ggrachdev.debugbar/filters.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,29 @@
2727
return $data;
2828
})
2929
->addFilter('methods', function ($data, $filterParams) {
30-
if (\is_object($data) && !empty($data)) {
31-
$data = get_class_methods($data);
30+
if (\is_object($data)) {
31+
$data = \get_class_methods($data);
32+
echo '<pre>';
33+
print_r($data);
34+
echo '</pre>';
35+
}
36+
37+
return $data;
38+
})
39+
->addFilter('classPath', function ($data, $filterParams) {
40+
if (\is_object($data) || \class_exists($data)) {
41+
$reflectionClass = new \ReflectionClass($data);
42+
$data = [
43+
'file_name' => $reflectionClass->getFileName(),
44+
'start_line' => $reflectionClass->getStartLine()
45+
];
46+
}
47+
48+
return $data;
49+
})
50+
->addFilter('props', function ($data, $filterParams) {
51+
if (\is_object($data)) {
52+
$data = \get_object_vars($data);
3253
}
3354

3455
return $data;
@@ -58,5 +79,12 @@
5879
$data = array_pop($data);
5980
}
6081

82+
return $data;
83+
})
84+
->addFilter('filter', function ($data, $filterParams) {
85+
if (!empty($filterParams[0]) && \is_callable($filterParams[0])) {
86+
$data = $filterParams[0]($data);
87+
}
88+
6189
return $data;
6290
});

0 commit comments

Comments
 (0)