vendor/braintree/braintree_php/lib/Braintree/Xml/Generator.php
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Braintree\Xml;
use DateTime;
use DateTimeZone;
use XMLWriter;
use Braintree\Util;
/**
* Generates XML output from arrays using PHP's
* built-in XMLWriter
*/
class Generator
{
/**
* arrays passed to this method should have a single root element
* with an array as its value
*
* @param array $aData the array of data
*
* @return string XML string
*/
public static function arrayToXml($aData)
{
$aData = Util::camelCaseToDelimiterArray($aData, '-');
// set up the XMLWriter
$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->setIndentString(' ');
$writer->startDocument('1.0', 'UTF-8');
// get the root element name
$aKeys = array_keys($aData);
$rootElementName = $aKeys[0];
// open the root element
$writer->startElement($rootElementName);
// create the body
self::_createElementsFromArray($writer, $aData[$rootElementName], $rootElementName);
// close the root element and document
$writer->endElement();
$writer->endDocument();
// send the output as string
return $writer->outputMemory();
}
/**
* Construct XML elements with attributes from an associative array.
*
* @param object $writer XMLWriter object
* @param array $aData contains attributes and values
*
* @return void
*/
private static function _createElementsFromArray(&$writer, $aData)
{
后面还有 95 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
