本文整理汇总了PHP中MantisEnum::getAssocArrayIndexedByLabels方法的典型用法代码示例。如果您正苦于以下问题:PHP MantisEnum::getAssocArrayIndexedByLabels方法的具体用法?PHP MantisEnum::getAssocArrayIndexedByLabels怎么用?PHP MantisEnum::getAssocArrayIndexedByLabels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MantisEnum
的用法示例。
在下文中一共展示了MantisEnum::getAssocArrayIndexedByLabels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAssocArrayIndexedByLabels
/**
* Tests getAssocArrayIndexedByLabels() method.
*/
public function testGetAssocArrayIndexedByLabels()
{
$this->assertEquals(array(), MantisEnum::getAssocArrayIndexedByLabels(MantisEnumTest::EMPTY_ENUM));
$this->assertEquals(array('viewer' => 10), MantisEnum::getAssocArrayIndexedByLabels(MantisEnumTest::SINGLE_VALUE_ENUM));
$this->assertEquals(array('viewer1' => 10), MantisEnum::getAssocArrayIndexedByLabels(MantisEnumTest::DUPLICATE_VALUES_ENUM));
$this->assertEquals(array('viewer' => 10, 'viewer' => 20), MantisEnum::getAssocArrayIndexedByLabels(MantisEnumTest::DUPLICATE_LABELS_ENUM));
$this->assertEquals(array('first label' => 10, 'second label' => 20), MantisEnum::getAssocArrayIndexedByLabels(MantisEnumTest::NAME_WITH_SPACES_ENUM));
}
示例2: getValue
/**
* Gets the value associated with the specified label.
*
* @param string $enumString The enumerated string.
* @param string $label The label to map.
* @return integer value of the enum or false if not found.
*/
public static function getValue($enumString, $label)
{
$assocArrayByLabels = MantisEnum::getAssocArrayIndexedByLabels($enumString);
if (isset($assocArrayByLabels[$label])) {
return $assocArrayByLabels[$label];
}
return false;
}
示例3: getValue
/**
* Gets the value associated with the specified label.
*
* @param string $p_enum_string The enumerated string.
* @param string $p_label The label to map.
* @return integer value of the enumeration or false if not found.
*/
public static function getValue($p_enum_string, $p_label)
{
$t_assoc_array_by_labels = MantisEnum::getAssocArrayIndexedByLabels($p_enum_string);
if (isset($t_assoc_array_by_labels[$p_label])) {
return $t_assoc_array_by_labels[$p_label];
}
return false;
}