/** * Detect the current environment from an environment configuration. * * @param array $environments * @param string $uri * @return string|null */ public static function detect_env(array $environments, $uri) { foreach ($environments as $environment => $patterns) { // Essentially we just want to loop through each environment pattern // and determine if the current URI matches the pattern and if so // we will simply return the environment for that URI pattern. foreach ($patterns as $pattern) { if (Str::is($pattern, $uri)) { return $environment; } } } }
/** * Determine if a given string matches a given pattern. * * @param string $pattern * @param string $value * @return bool */ function str_is($pattern, $value) { return Str::is($pattern, $value); }
public static function is($pattern) { return Str::is($pattern, self::current()); }