本文整理汇总了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));
}