예제 #1
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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;
 }