Beispiel #1
0
 /**
  * Compare given value in a [List|of|Possible|Values]
  *
  * @param string $value
  *   Value to compare
  *
  * @param string $list
  *   List to compare given value
  *
  * @return string|NULL
  *
  *   - If given parameter lacks the Separator Token OR
  *     if it IS present in a List of Possible Values, it will be returned "as is"
  *
  *   - Otherwise we'll try to find the proper Default Value.
  *     If we succeed, this value will be returned. Otherwise NULL will
  */
 private function compareWithList($value, $list)
 {
     // Mal-formed List?
     if (strpos($list, self::SEPARATOR_TOKEN) === FALSE) {
         // Let's use what we received
         return $value;
     } else {
         // Parameter is in the List?
         // Removing Default Value Definition of given list in order to split correctly
         $l = preg_replace(sprintf('/%s/', self::DEFAULT_VALUE_REGEXP), '', $list);
         if (ArrayUtils::in($value, explode(self::SEPARATOR_TOKEN, $l))) {
             return $value;
         }
         // No? Let's try to find the Default Value
         return $this->getDefaultValue($list);
     }
 }