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