Skip to content
Browse files

Stringify objects (couldn't cherry pick this commit)

  • Loading branch information...
1 parent 4433557 commit 8cab04a84445292004620fcb9e2f1d8366b185b6 @snikch snikch committed Oct 10, 2011
Showing with 15 additions and 1 deletion.
  1. +15 −1 Services/Airbrake.php
View
16 Services/Airbrake.php
@@ -268,12 +268,26 @@ function addXmlVars($parent, $key, $source)
$node = $parent->addChild($key);
foreach ($source as $key => $val) {
- $var_node = $node->addChild('var', $val);
+ $var_node = $node->addChild('var', $this->dumpVar($val));
$var_node->addAttribute('key', $key);
}
}
/**
+
+ * Make a string representation of an a variable of arbitrary type
+ * @return string
+ * @author Christian Rishoj Jensen
+ **/
+ function dumpVar($var)
+ {
+ if (is_array($var) || is_object($var))
+ $var = trim(preg_replace("/\n */", " ", print_r($var, true)));
+ return $var;
+ }
+
+ /**
+ *
* Add a Airbrake backtrace to the XML
* @return void
* @author Rich Cavanaugh

0 comments on commit 8cab04a

Please sign in to comment.
Something went wrong with that request. Please try again.