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


PHP Format::printfFormatIsoToPhp方法代码示例

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


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

示例1: processValue

 /**
  * Process a $value depending on its $baseType.
  * 
  * @param integer $baseType The baseType of the value to process.
  * @param mixed $value A QTI Runtime compliant value.
  * @throws PrintedVariableProcessingException If the baseType is unknown.
  * @return string
  */
 private function processValue($baseType, $value)
 {
     $printedVariable = $this->getComponent();
     if ($value === null) {
         return 'null';
     }
     if ($baseType === BaseType::INT_OR_IDENTIFIER) {
         $baseType = is_int($value) === true ? BaseType::INTEGER : BaseType::STRING;
     } else {
         if ($baseType === BaseType::IDENTIFIER || $baseType === BaseType::URI) {
             $baseType = BaseType::STRING;
         } else {
             if ($baseType === BaseType::FILE) {
                 // @todo support baseType::FILE in PrintedVariable.
                 $msg = "the 'file' BaseType is not supported yet by PrintedVariableEngine implementation.";
                 throw new PrintedVariableProcessingException($msg, $this, PrintedVariableProcessingException::RUNTIME_ERROR);
             }
         }
     }
     if ($baseType === BaseType::STRING) {
         return $value->getValue();
     } else {
         if ($baseType === BaseType::INTEGER || $baseType === BaseType::FLOAT) {
             $format = $printedVariable->getFormat();
             if (empty($format) === false) {
                 $format = Format::printfFormatIsoToPhp($format);
                 return sprintf($format, $value->getValue());
             } else {
                 if ($baseType === BaseType::FLOAT && $printedVariable->mustPowerForm() === true) {
                     return Format::scale10($value->getValue(), 'x');
                 } else {
                     if ($baseType === BaseType::FLOAT) {
                         return sprintf('%e', $value->getValue());
                     } else {
                         // integer to string
                         return '' . $value->getValue();
                     }
                 }
             }
         } else {
             if ($baseType === BaseType::DURATION) {
                 return '' . $value->getSeconds(true);
             } else {
                 if ($baseType === BaseType::BOOLEAN) {
                     return $value->getValue() === true ? 'true' : 'false';
                 } else {
                     if ($baseType === BaseType::POINT || $baseType === BaseType::PAIR || $baseType === BaseType::DIRECTED_PAIR) {
                         return $value->__toString();
                     } else {
                         $msg = "Unknown value type.";
                         throw new PrintedVariableProcessingException($msg, $this, PrintedVariableProcessingException::RUNTIME_ERROR);
                     }
                 }
             }
         }
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:65,代码来源:PrintedVariableEngine.php

示例2: testPrintfFormatIsoToPhp

 /**
  * @dataProvider printfFormatIsoToPhpProvider 
  * 
  * @param string $input
  * @param boolean $expected
  */
 public function testPrintfFormatIsoToPhp($input, $expected)
 {
     $this->assertEquals($expected, Format::printfFormatIsoToPhp($input));
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:10,代码来源:FormatTest.php


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