Skip to content

Commit 33cdca3

Browse files
committed
person_fn type checking & object handling
1 parent 01bbe7a commit 33cdca3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/MonologHandler.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,17 @@ protected function addContext(array $context = [])
4343
} else {
4444
if (isset($config['person_fn']) && is_callable($config['person_fn'])) {
4545
$data = @call_user_func($config['person_fn']);
46-
if (isset($data['id'])) {
47-
$person = call_user_func($config['person_fn']);
46+
if (! empty($data)) {
47+
if (is_object($data)) {
48+
if (method_exists($data, 'toArray')) {
49+
$data = $data->toArray();
50+
} else {
51+
$data = (array)$data;
52+
}
53+
}
54+
if (isset($data['id'])) {
55+
$person = $data;
56+
}
4857
}
4958
}
5059
}

0 commit comments

Comments
 (0)