本文整理汇总了PHP中Set::enum方法的典型用法代码示例。如果您正苦于以下问题:PHP Set::enum方法的具体用法?PHP Set::enum怎么用?PHP Set::enum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set::enum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEnum
/**
* testEnum method
*
* @return void
*/
public function testEnum()
{
$result = Set::enum(1, 'one, two');
$this->assertEquals('two', $result);
$result = Set::enum(2, 'one, two');
$this->assertNull($result);
$set = array('one', 'two');
$result = Set::enum(0, $set);
$this->assertEquals('one', $result);
$result = Set::enum(1, $set);
$this->assertEquals('two', $result);
$result = Set::enum(1, array('one', 'two'));
$this->assertEquals('two', $result);
$result = Set::enum(2, array('one', 'two'));
$this->assertNull($result);
$result = Set::enum('first', array('first' => 'one', 'second' => 'two'));
$this->assertEquals('one', $result);
$result = Set::enum('third', array('first' => 'one', 'second' => 'two'));
$this->assertNull($result);
$result = Set::enum('no', array('no' => 0, 'yes' => 1));
$this->assertEquals(0, $result);
$result = Set::enum('not sure', array('no' => 0, 'yes' => 1));
$this->assertNull($result);
$result = Set::enum(0);
$this->assertEquals('no', $result);
$result = Set::enum(1);
$this->assertEquals('yes', $result);
$result = Set::enum(2);
$this->assertNull($result);
}
示例2: testEnum
/**
* testEnum method
*
* @access public
* @return void
*/
function testEnum()
{
$result = Set::enum(1, 'one, two');
$this->assertIdentical($result, 'two');
$result = Set::enum(2, 'one, two');
$this->assertNull($result);
$result = Set::enum(1, array('one', 'two'));
$this->assertIdentical($result, 'two');
$result = Set::enum(2, array('one', 'two'));
$this->assertNull($result);
$result = Set::enum('first', array('first' => 'one', 'second' => 'two'));
$this->assertIdentical($result, 'one');
$result = Set::enum('third', array('first' => 'one', 'second' => 'two'));
$this->assertNull($result);
$result = Set::enum('no', array('no' => 0, 'yes' => 1));
$this->assertIdentical($result, 0);
$result = Set::enum('not sure', array('no' => 0, 'yes' => 1));
$this->assertNull($result);
}
示例3: getReturnedMessage
public function getReturnedMessage($code)
{
return empty($code) ? '' : Set::enum($code, $this->returned_messages);
}
示例4: _modifyChecks_r
function _modifyChecks_r(&$array)
{
static $condEnum = array('logical' => array('not' => CHECK_CONDITION_LOGICAL_NOT, 'and' => CHECK_CONDITION_LOGICAL_AND, 'or' => CHECK_CONDITION_LOGICAL_OR, 'atleast' => CHECK_CONDITION_LOGICAL_AT_LEAST, 'atmost' => CHECK_CONDITION_LOGICAL_AT_MOST), 'registry' => array('exist' => CHECK_CONDITION_REGISTRY_EXISTS, 'equals' => CHECK_CONDITION_REGISTRY_EQUALS), 'file' => array('exists' => CHECK_CONDITION_FILE_EXISTS, 'sizeequals' => CHECK_CONDITION_FILE_SIZE_EQUALS, 'versionsmallerthan' => CHECK_CONDITION_FILE_VERSION_SMALLER_THAN, 'versionlessorequal' => CHECK_CONDITION_FILE_VERSION_LESS_THAN_OR_EQUAL_TO, 'versionequalto' => CHECK_CONDITION_FILE_VERSION_EQUAL_TO, 'versiongreaterthan' => CHECK_CONDITION_FILE_VERSION_GREATER_THAN, 'versiongreaterorequal' => CHECK_CONDITION_FILE_VERSION_GREATER_THAN_OR_EQUAL_TO), 'execute' => array('exitcodesmallerthan' => CHECK_CONDITION_EXECUTE_EXIT_CODE_SMALLER_THAN, 'exitcodelessorequal' => CHECK_CONDITION_EXECUTE_EXIT_CODE_LESS_THAN_OR_EQUAL_TO, 'exitcodeequalto' => CHECK_CONDITION_EXECUTE_EXIT_CODE_EQUAL_TO, 'exitcodegreaterthan' => CHECK_CONDITION_EXECUTE_EXIT_CODE_GREATER_THAN, 'exitcodegreaterorequal' => CHECK_CONDITION_EXECUTE_EXIT_CODE_GREATER_THAN_OR_EQUAL_TO), 'uninstall' => array('exists' => CHECK_CONDITION_UNINSTALL_EXISTS));
$array['condition'] = Set::enum(strtolower($array['condition']), $condEnum[strtolower($array['type'])]);
$array['type'] = constant('CHECK_TYPE_' . strtoupper($array['type']));
if (isset($array['Childcheck']) && $array['type'] == CHECK_TYPE_LOGICAL) {
$this->_arrayify($array['Childcheck']);
for ($i = 0; $i < count($array['Childcheck']); $i++) {
$this->_modifyChecks_r($array['Childcheck'][$i]);
}
}
}