本文整理汇总了PHP中CPropertyValue::ensureFloat方法的典型用法代码示例。如果您正苦于以下问题:PHP CPropertyValue::ensureFloat方法的具体用法?PHP CPropertyValue::ensureFloat怎么用?PHP CPropertyValue::ensureFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPropertyValue
的用法示例。
在下文中一共展示了CPropertyValue::ensureFloat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEnsureFloat
public function testEnsureFloat()
{
$entries = array(array(123, 123.0), array(1.23, 1.23), array(null, 0.0), array('', 0.0), array('abc', 0.0), array('123', 123.0), array('1.23', 1.23), array(' 1.23', 1.23), array(' 1.23abc', 1.23), array('abc1.23abc', 0.0), array(true, 1.0), array(false, 0.0), array(array(), 0.0), array(array(0), 1.0));
foreach ($entries as $index => $entry) {
$this->assertTrue(CPropertyValue::ensureFloat($entry[0]) === $entry[1], "Comparison {$index}: {$this->varToString($entry[0])}=={$this->varToString($entry[1])}");
}
}
示例2: init
public function init()
{
$this->maxBlockTime = $this->getTimeInterval($this->maxBlockTime);
$this->alertRepeatInterval = $this->getTimeInterval($this->alertRepeatInterval);
$this->gatewayMinCredit = CPropertyValue::ensureFloat($this->gatewayMinCredit);
$gateways = array();
foreach ($this->gateways as $gateway) {
$gateways[] = Yii::createComponent($gateway);
}
$this->gateways = $gateways;
}
示例3: convertType
public function convertType($value)
{
$value = trim($value);
if (ctype_digit($value)) {
return CPropertyValue::ensureInteger($value);
}
if (is_numeric($value)) {
return CPropertyValue::ensureFloat($value);
}
if (strcasecmp($value, 'null') == 0) {
return null;
} else {
if (strcasecmp($value, 'true') == 0 || strcasecmp($value, 'false') == 0) {
return CPropertyValue::ensureBoolean($value);
} else {
if (preg_match('/^\\(.+\\)|\\(\\)$/', $value)) {
return CPropertyValue::ensureArray($value);
}
}
}
return $value;
}
示例4: setTimeLimit
public function setTimeLimit($value)
{
$this->_timeLimit = CPropertyValue::ensureFloat($value);
}
示例5: getInput
/**
* Extract an data from input data
*
* @param string $name can be an normal name or 'Class[attribute]' to get input of a model attribute
*
* @param mixed $defaultValue it is recommended to specify default value even when you
* are sure that the input has data you want to extract.
*
* @param string $filter 'xss,notag,newline' filters the data is run through before returned
* do not combine xss with notag as it slow down the performance.
*/
public function getInput($name, $defaultValue = null, $filter = '')
{
if (is_array($parsedName = $this->parseName($name))) {
$name = $parsedName[0];
$key = $parsedName[1];
}
if (!array_key_exists($name, $this->data)) {
return $defaultValue;
} else {
$value = $this->data[$name];
if (isset($key) && is_array($value)) {
$value = $value[$key];
}
if (is_null($value)) {
return $defaultValue;
}
}
//Run filters
if (is_string($value) || is_array($value)) {
foreach ($this->filters as $flt) {
$value = call_user_func(array($this, $flt), $value, $filter);
}
}
if (is_array($value)) {
return $value;
}
$value = trim($value);
//Convert to expected type
if (is_null($defaultValue)) {
return trim($value);
}
if (is_string($defaultValue)) {
return CPropertyValue::ensureString($value);
}
if (is_int($defaultValue)) {
return CPropertyValue::ensureInteger($value);
}
if (is_numeric($defaultValue)) {
return CPropertyValue::ensureFloat($value);
}
if (is_array($defaultValue)) {
if (!is_array($value)) {
return array($value);
} else {
return $value;
}
}
return $value;
}
示例6: init
public function init()
{
$this->minCredit = CPropertyValue::ensureFloat($this->minCredit);
}