当前位置: 首页>>代码示例>>PHP>>正文


PHP DOMElement::queryOne方法代码示例

本文整理汇总了PHP中DOMElement::queryOne方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::queryOne方法的具体用法?PHP DOMElement::queryOne怎么用?PHP DOMElement::queryOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DOMElement的用法示例。


在下文中一共展示了DOMElement::queryOne方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processVariant

 private function processVariant(Subject $subject, Variant $variant, \DOMElement $subjectEl)
 {
     $variantEl = $subjectEl->appendElement('variant');
     // TODO: These attributes should be on the subject, see
     // https://github.com/phpbench/phpbench/issues/307
     $variantEl->setAttribute('sleep', $subject->getSleep());
     $variantEl->setAttribute('output-time-unit', $subject->getOutputTimeUnit() ?: TimeUnit::MICROSECONDS);
     $variantEl->setAttribute('output-time-precision', $subject->getOutputTimePrecision());
     $variantEl->setAttribute('output-mode', $subject->getOutputMode() ?: TimeUnit::MODE_TIME);
     $variantEl->setAttribute('revs', $variant->getRevolutions());
     $variantEl->setAttribute('warmup', $variant->getWarmup());
     $variantEl->setAttribute('retry-threshold', $subject->getRetryThreshold());
     foreach ($variant->getParameterSet() as $name => $value) {
         $this->createParameter($variantEl, $name, $value);
     }
     if ($variant->hasErrorStack()) {
         $errorsEl = $variantEl->appendElement('errors');
         foreach ($variant->getErrorStack() as $error) {
             $errorEl = $errorsEl->appendElement('error', $error->getMessage());
             $errorEl->setAttribute('exception-class', $error->getClass());
             $errorEl->setAttribute('code', $error->getCode());
             $errorEl->setAttribute('file', $error->getFile());
             $errorEl->setAttribute('line', $error->getLine());
         }
         return;
     }
     $stats = $variant->getStats();
     $stats = iterator_to_array($stats);
     $resultClasses = [];
     // ensure same order (for testing)
     ksort($stats);
     foreach ($variant as $iteration) {
         $iterationEl = $variantEl->appendElement('iteration');
         foreach ($iteration->getResults() as $result) {
             // we need to store the class FQNs of the results for deserialization later.
             if (!isset($resultClasses[$result->getKey()])) {
                 $resultClasses[$result->getKey()] = get_class($result);
             }
             $prefix = $result->getKey();
             $metrics = $result->getMetrics();
             foreach ($metrics as $key => $value) {
                 $iterationEl->setAttribute(sprintf('%s-%s', $prefix, str_replace('_', '-', $key)), $value);
             }
         }
     }
     $statsEl = $variantEl->appendElement('stats');
     foreach ($stats as $statName => $statValue) {
         $statsEl->setAttribute($statName, $statValue);
     }
     foreach ($resultClasses as $resultKey => $classFqn) {
         if ($subjectEl->queryOne('ancestor::suite/result[@key="' . $resultKey . '"]')) {
             continue;
         }
         $resultEl = $subjectEl->queryOne('ancestor::suite')->appendElement('result');
         $resultEl->setAttribute('key', $resultKey);
         $resultEl->setAttribute('class', $classFqn);
     }
 }
开发者ID:dantleech,项目名称:phpbench,代码行数:58,代码来源:XmlEncoder.php


注:本文中的DOMElement::queryOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。