本文整理汇总了PHP中CM_Params::getFloat方法的典型用法代码示例。如果您正苦于以下问题:PHP CM_Params::getFloat方法的具体用法?PHP CM_Params::getFloat怎么用?PHP CM_Params::getFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CM_Params
的用法示例。
在下文中一共展示了CM_Params::getFloat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajax_getSuggestionByCoordinates
public function ajax_getSuggestionByCoordinates(CM_Params $params, CM_Frontend_JavascriptContainer_View $handler, CM_Http_Response_View_Ajax $response)
{
$lat = $params->getFloat('lat');
$lon = $params->getFloat('lon');
$location = CM_Model_Location::findByCoordinates($lat, $lon);
$location = $this->_squashLocationInConstraints($location);
if (!$location) {
throw new CM_Exception('Cannot find a location by coordinates `' . $lat . '` / `' . $lon . '`.');
}
return $this->getSuggestion($location, $response->getRender());
}
示例2: testGetFloat
public function testGetFloat()
{
$testDataList = array(array(34.28, 34.28), array(-34.28, -34.28), array(0.0, 0.0), array(-34.0, -34), array(34.0, 34), array(0.0, 0), array(34.28, '34.28'), array(-34.28, '-34.28'), array(34.2, '34.2'), array(-34.2, '-34.2'), array(34.0, '34.'), array(-34.0, '-34.'), array(4.28, '4.28'), array(-4.28, '-4.28'), array(0.28, '.28'), array(-0.28, '-.28'), array(0.28, '0.28'), array(-0.28, '-0.28'), array(0.0, '0.'), array(0.0, '-0.'), array(0.0, '.0'), array(0.0, '-.0'), array(34.0, '34'), array(-34.0, '-34'), array(0.0, '0'), array(0.0, '-0'));
foreach ($testDataList as $testData) {
$expected = $testData[0];
$userInput = $testData[1];
$params = new CM_Params(array('userInput' => $userInput));
$this->assertSame($expected, $params->getFloat('userInput'));
}
$userInputInvalidList = array('', '-', '.', '-.', '1.2.3', '12 ', ' 12', '12,345', false, true, array('1'), new stdClass(), fopen(__FILE__, 'r'));
foreach ($userInputInvalidList as $userInputInvalid) {
$params = new CM_Params(array('userInput' => $userInputInvalid));
try {
$params->getFloat('userInput');
$this->fail('User input is not a float');
} catch (CM_Exception_InvalidParam $e) {
$this->assertTrue(true);
}
}
}