本文整理匯總了PHP中SpoonFilter::isMinimumCharacters方法的典型用法代碼示例。如果您正苦於以下問題:PHP SpoonFilter::isMinimumCharacters方法的具體用法?PHP SpoonFilter::isMinimumCharacters怎麽用?PHP SpoonFilter::isMinimumCharacters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SpoonFilter
的用法示例。
在下文中一共展示了SpoonFilter::isMinimumCharacters方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isMinimumCharacters
/**
* Checks if this field's length is more than or equal to the given minimum.
*
* @return bool
* @param int $minimum The minimum number of characters.
* @param string[optional] $error The error message to set.
*/
public function isMinimumCharacters($minimum, $error = null)
{
// filled
if ($this->isFilled()) {
// post/get data
$data = $this->getMethod(true);
// validate
if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isMinimumCharacters($minimum, $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: testIsMinimumCharacters
public function testIsMinimumCharacters()
{
$string = 'Ik heb er géén gedacht van';
$this->assertTrue(SpoonFilter::isMinimumCharacters(10, $string, 'utf-8'));
$this->assertFalse(SpoonFilter::isMinimumCharacters(30, $string, 'utf-8'));
$this->assertTrue(SpoonFilter::isMinimumCharacters(10, utf8_decode($string), 'iso-8859-1'));
}