本文整理汇总了PHP中Zend_Filter::isBetween方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter::isBetween方法的具体用法?PHP Zend_Filter::isBetween怎么用?PHP Zend_Filter::isBetween使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Filter
的用法示例。
在下文中一共展示了Zend_Filter::isBetween方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsBetween
public function testIsBetween()
{
$this->assertTrue(Zend_Filter::isBetween(10, 1, 20, FALSE), '"10" is between "1" and "20" non inclusive');
$this->assertTrue(Zend_Filter::isBetween(10, 1, 10), '"10" is between "1" and "20" inclusive');
$this->assertFalse(Zend_Filter::isBetween(10, 1, 9, FALSE), '"10" is not between "1" and "9" inclusive');
$this->assertFalse(Zend_Filter::isBetween(10, 1, 9), '"10" is not between "1" and "9" inclusive');
}
示例2: _validateWebSearch
/**
* Validate Web Search Options
*
* @param array $options
*/
protected function _validateWebSearch($options)
{
$valid_options = array('appid', 'query', 'results', 'start', 'language', 'type', 'format', 'adult_ok', 'similar_ok', 'country', 'site', 'subscription', 'license');
if (!is_array($options)) {
return;
}
$this->_compareOptions($options, $valid_options);
if (isset($options['results'])) {
if (!Zend_Filter::isBetween($options['results'], 1, 20, true)) {
throw new Zend_Service_Exception($options['results'] . ' is not valid for the "results" option.');
}
}
if (isset($options['start'])) {
if (!Zend_Filter::isBetween($options['start'], 1, 1000, true)) {
throw new Zend_Service_Exception($options['start'] . ' is not valid for the "start" option.');
}
}
$this->_validateLanguage($options['language']);
$this->_validateInArray('query type', $options['type'], array('all', 'any', 'phrase'));
$this->_validateInArray('format', $options['format'], array('any', 'html', 'msword', 'pdf', 'ppt', 'rss', 'txt', 'xls'));
$this->_validateInArray('license', $options['license'], array('any', 'cc_any', 'cc_commercial', 'cc_modifiable'));
}
示例3: _validateItemLookup
/**
* Validate options for an ItemLookup
*
* @param array $options Options array to be used for the query
* @throws Zend_Service_Exception
* @return void
*/
protected function _validateItemLookup($options = array())
{
if (!is_array($options)) {
throw new Zend_Service_Exception('Options must be specified as an array');
}
// Validate keys in the $options array
$this->_compareOptions($options, array('ItemId', 'IdType', 'SearchIndex', 'MerchantId', 'Condition', 'DeliveryMethod', 'ISPUPostalCode', 'OfferPage', 'ReviewPage', 'VariationPage', 'ResponseGroup', 'Service', 'SubscriptionId', 'Operation'));
// Validate ResponseGroup (required)
if (empty($options['ResponseGroup'])) {
throw new Zend_Service_Exception('Query requires a ResponseGroup');
} else {
$responseGroup = split(',', $options['ResponseGroup']);
foreach ($responseGroup as $r) {
if (!in_array($r, array('Request', 'Small', 'Medium', 'Large'))) {
throw new Zend_Service_Exception('This wrapper only supports Request, Small, Medium and Large ' . 'ResponseGroups');
}
}
}
// Validate Sort (optional)
if (isset($options['Sort'])) {
$this->_validateInArray('Sort', $options['Sort'], array_values(self::$_searchSort[$options['SearchIndex']]));
}
// Validate City (optional)
if (isset($options['City'])) {
$this->_validateInArray('City', $options['City'], array('Boston', 'Chicago', 'New York', 'San Francisco', 'Seattle', 'Washington, D.C.'));
}
if (isset($options['ItemPage'])) {
if (!Zend_Filter::isBetween($options['ItemPage'], 0, 2500, true)) {
throw new Zend_Service_Exception($options['ItemPage'] . ' is not a valid value for the "ItemPage" option.');
}
}
}
示例4: testBetween
/**
* Returns value if it is greater than or equal to $min and less
* than or equal to $max, FALSE otherwise. If $inc is set to
* FALSE, then the value must be strictly greater than $min and
* strictly less than $max.
*
* @param mixed $key
* @param mixed $min
* @param mixed $max
* @param boolean $inclusive
* @return mixed
*/
public function testBetween($key, $min, $max, $inc = TRUE)
{
if (!$this->keyExists($key)) {
return false;
}
if (Zend_Filter::isBetween($this->_source[$key], $min, $max, $inc)) {
return $this->_source[$key];
}
return FALSE;
}
示例5: _validateTagSearch
/**
* Validate Tag Search Options
*
* @param array $options
*/
protected function _validateTagSearch($options)
{
$valid_options = array('api_key', 'method', 'user_id', 'per_page', 'page', 'extras', 'min_upload_date', 'min_taken_date', 'max_upload_date', 'max_taken_date', 'tag_mode', 'tags');
if (!is_array($options)) {
return;
}
$this->_compareOptions($options, $valid_options);
if (!Zend_Filter::isBetween($options['per_page'], 1, 500, true)) {
throw new Zend_Service_Exception($options['per_page'] . ' is not valid for the "per_page" option');
}
if (!Zend_Filter::isInt($options['page'])) {
throw new Zend_Service_Exception($options['page'] . ' is not valid for the "page" option');
}
// validate extras, which are delivered in csv format
if ($options['extras']) {
$extras = explode(',', $options['extras']);
$valid_extras = array('license', 'date_upload', 'date_taken', 'owner_name', 'icon_server');
foreach ($extras as $extra) {
/**
* @todo The following does not do anything [yet], so it is commented out.
*/
//in_array(trim($extra), $valid_extras);
}
}
}
示例6: isBetween
/**
* Returns value if it is greater than or equal to $min and less
* than or equal to $max, FALSE otherwise. If $inc is set to
* FALSE, then the value must be strictly greater than $min and
* strictly less than $max.
*
* @param mixed $key
* @param mixed $min
* @param mixed $max
* @param boolean $inclusive
* @return mixed
*/
public function isBetween($key, $min = NULL, $max = NULL, $inc = TRUE)
{
return Zend_Filter::isBetween($this->_source[$key], $min, $max, $inc);
}
示例7: testBetween
/**
* Returns value if it is greater than or equal to $min and less
* than or equal to $max, FALSE otherwise. If $inc is set to
* FALSE, then the value must be strictly greater than $min and
* strictly less than $max.
*
* @param mixed $key
* @param mixed $min
* @param mixed $max
* @param boolean $inclusive
* @return mixed
*/
public function testBetween($key = null, $min, $max, $inc = TRUE)
{
if (!($value = $this->keyExists($key))) {
return false;
}
if (Zend_Filter::isBetween($value, $min, $max, $inc)) {
return $value;
}
return FALSE;
}