Returns Enum by value

@param string $value
@param bool $caseInsensitive
@return static
327984
public static function fromStrValue($value, $caseInsensitive = false)
    {
        foreach (static::values() as $key => $enumInstance) {
            if (is_string($enumInstance->getValue())) {
                if (!$caseInsensitive && $enumInstance->getValue() === $value) {
                    return $enumInstance;
                }

                if ($caseInsensitive && strcasecmp($enumInstance->getValue(), $value) === 0) {
                    return $enumInstance;
                }
            }
        }

        return null;
    }
808697
public function compare($compare, $caseSensitive = true)
    {
        if ($caseSensitive) {
            return Mbstring::strcmp($this->string, $compare);
        }

        return Mbstring::strcasecmp($this->string, $compare, $this->encoding);
    }
625122
final public static function byValue($value)
    {
        if (!isset(self::$constants[static::class])) {
            self::detectConstants(static::class);
        }

        $name = \array_search($value, self::$constants[static::class], true);
        if ($name === false) {
            throw new InvalidArgumentException(sprintf(
                'Unknown value %s for enumeration %s',
                \is_scalar($value)
                    ? \var_export($value, true)
                    : 'of type ' . (\is_object($value) ? \get_class($value) : \gettype($value)),
                static::class
            ));
        }

        if (!isset(self::$instances[static::class][$name])) {
            self::$instances[static::class][$name] = new static(self::$constants[static::class][$name]);
        }

        return self::$instances[static::class][$name];
    }
308771
public function enum($model, $key = null, $value = null) {
        $alias = is_string($model) ? $model : $model->alias;

        if (!isset($this->_enums[$alias])) {
            throw new InvalidArgumentException(sprintf('%s::$enum does not exist', $alias));
        }

        $enum = $this->_enums[$alias];

        if ($key) {
            if (!isset($enum[$key])) {
                throw new OutOfBoundsException(sprintf('Field %s does not exist within %s::$enum', $key, $model->alias));
            }

            if ($value !== null) {
                return isset($enum[$key][$value]) ? $enum[$key][$value] : null;
            } else {
                return $enum[$key];
            }
        }

        return $enum;
    }
762947
public static boolean isCaseInsensitive()
  {
    Boolean value = _caseInsensitive.get();

    if (value == null) {
      return _isCaseInsensitive;
    }
    else
      return value.booleanValue();
  }
926908
public function setValues(array $values, $caseSensitive = false)
	{
		if (!is_bool($caseSensitive))
		{
			throw new InvalidArgumentException('Argument 2 passed to ' . __METHOD__ . ' must be a boolean');
		}

		// Create a regexp based on the list of allowed values
		$regexp = RegexpBuilder::fromList($values, ['delimiter' => '/']);
		$regexp = '/^' . $regexp . '$/D';

		// Add the case-insensitive flag if applicable
		if (!$caseSensitive)
		{
			$regexp .= 'i';
		}

		// Add the Unicode flag if the regexp isn't purely ASCII
		if (!preg_match('#^[[:ascii:]]*$#D', $regexp))
		{
			$regexp .= 'u';
		}

		// Set the regexp associated with this list of values
		$this->setRegexp($regexp);
	}
865868
public function asEnum($value, $enumName)
    {
        if (!isset($this->enums[$enumName])) {
            throw new InvalidParamException("The '$enumName' enum has not been registered in the current formatter");
        }
        if ($value === null) {
            return $this->nullDisplay;
        }
        return isset($this->enums[$enumName][$value]) ? $this->enums[$enumName][$value] : $value;
    }
239392
public function getTypeFromValue($value = null)
    {
        $value = ($value == null ? $this->value : $value);
        return array_search($this->value, self::$statusList);
    }
20205
public static function compile(Compiler $compiler, $value, $search, $replace, $case_sensitive = true)
    {
        if ($case_sensitive == 'false' || (bool)$case_sensitive === false) {
            return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')';
        } else {
            return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')';
        }
    }
253999
public static function to_type(&$value, string $type='', bool $flatten=false) {
		switch (\strtolower($type)) {
			case 'string':
				static::string($value, $flatten);
				break;
			case 'int':
			case 'integer':
				static::int($value, $flatten);
				break;
			case 'double':
			case 'float':
			case 'number':
				static::float($value, $flatten);
				break;
			case 'bool':
			case 'boolean':
				static::bool($value, $flatten);
				break;
			case 'array':
				static::array($value);
				break;
		}
	}
1338530
public static function getName($value)
    {
        $enumerables = self::getCache();
        $result = array_search($value, $enumerables, true);
        
        if ($result === false) {
            throw EnumerableException::valueNotFound();
        }
        
        return $result;
    }
758940
public static function inEnum($value)
    {
        $allItems = array_flip(self::toArray());

        return isset($allItems[$value]) ? true : false;
    }
4038
public String convertToUpperCase(String value) {
        String result = null;
        if (value != null) {
            result = value.toUpperCase();
        }
        return result;
    }
913981
public static function getValue($value)
    {
        if (is_string($value)) {
            return static::escapeText($value);
        }
        if (is_bool($value)) {
            return static::getBoolean($value);
        }
        if (is_array($value)) {
            return static::getArray($value);
        }
        return $value;
    }
526705
public static function getType($value)
    {
        if (preg_match(self::REGEXP_TCP, $value)) {
            return self::TYPE_TCP;
        }

        if (preg_match(self::REGEXP_SSL, $value)) {
            return self::TYPE_SSL;
        }

        if (preg_match(self::REGEXP_UNIX, $value)) {
            return self::TYPE_UNIX;
        }

        return null;
    }
298756
final public static function parseName(string $searchName, bool $caseInsensitive = false)
    {
        $constants = self::getClassConstants(static::class);

        if (isset($constants[$searchName])) {
            return $constants[$searchName];
        }

        if ($caseInsensitive && null !== $key = self::searchArrayCaseInsensitive($constants, $searchName)) {
            return $constants[$key];
        }

        throw new \InvalidArgumentException('Unknown enumeration member: ' . $searchName);
    }
532106
public static function equal($value, $target, $ignoreCase = false)
    {
        if ($ignoreCase) {
            if (is_string($value)) {
                $value = strtolower($value);
            }

            if (is_string($target)) {
                $target = strtolower($target);
            }
        }

        return $value === $target;
    }