code: protected function array2Node($parentNode, $key, $params)
      {
          if (count($params) == 0) {
              return;
          }
  
          $node = $parentNode->addChild($key);
          foreach ($params as $key => $value) {
              if (is_array($value) || is_object($value)) {
                  $value = json_encode((array) $value);
              }
  
              // htmlspecialchars() is needed to prevent html characters from breaking the node.
              $node->addChild('var', htmlspecialchars($value))
                  ->addAttribute('key', $key);
          }
      }
docs: Add a Airbrake var block to an XML node.
  
  @param SimpleXMLElement $parentNode
  @param string $key
  @param array $params