本文整理匯總了PHP中SpoonFilter::isMaximum方法的典型用法代碼示例。如果您正苦於以下問題:PHP SpoonFilter::isMaximum方法的具體用法?PHP SpoonFilter::isMaximum怎麽用?PHP SpoonFilter::isMaximum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SpoonFilter
的用法示例。
在下文中一共展示了SpoonFilter::isMaximum方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isMaximum
/**
* Checks if this field does not exceed the given maximum.
*
* @return bool
* @param int $maximum The maximum.
* @param int[optional] $error The error message to set.
*/
public function isMaximum($maximum, $error = null)
{
// filled
if ($this->isFilled()) {
// post/get data
$data = $this->getMethod(true);
// validate
if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isMaximum($maximum, $data[$this->attributes['name']])) {
if ($error !== null) {
$this->setError($error);
}
return false;
}
return true;
}
// not submitted
if ($error !== null) {
$this->setError($error);
}
return false;
}
示例2: testIsMaximum
public function testIsMaximum()
{
$this->assertTrue(SpoonFilter::isMaximum(10, 1));
$this->assertTrue(SpoonFilter::isMaximum(10, 10));
$this->assertTrue(SpoonFilter::isMaximum(-10, -10));
$this->assertFalse(SpoonFilter::isMaximum(100, 101));
$this->assertFalse(SpoonFilter::isMaximum(-100, -99));
// Again, showing the downright dangerous implications of casting as a
// defensive programming technique.
$this->assertTrue(SpoonFilter::isMaximum(array(), array()));
$this->assertTrue(SpoonFilter::isMaximum(array(1), array()));
$this->assertFalse(SpoonFilter::isMaximum(array(), array(1)));
$this->assertFalse(SpoonFilter::isMaximum(array(), 10));
$this->assertTrue(SpoonFilter::isMaximum(array(), 0));
$this->assertTrue(SpoonFilter::isMaximum(array(1), 0));
$this->assertTrue(SpoonFilter::isMaximum(array(1), 1));
$this->assertFalse(SpoonFilter::isMaximum(array(1), 2));
}
示例3: testIsMaximum
public function testIsMaximum()
{
$this->assertTrue(SpoonFilter::isMaximum(10, 1));
$this->assertTrue(SpoonFilter::isMaximum(10, 10));
$this->assertTrue(SpoonFilter::isMaximum(-10, -10));
$this->assertFalse(SpoonFilter::isMaximum(100, 101));
$this->assertFalse(SpoonFilter::isMaximum(-100, -99));
}