get Env Name By Domain
@param string $defaultEnv
@param null|string $domain
@return string
498248
public static function getEnvNameByDomain(string $defaultEnv = null, string $domain = null): string
    {
        $domain = $domain ?: PhpHelper::serverParam('HTTP_HOST');

        if (!$domain) {
            return $defaultEnv;
        }

        foreach (self::$domain2env as $kw => $env) {
            if (false !== strpos($domain, $kw)) {
                return $env;
            }
        }

        return $defaultEnv;
    }
943039
public function getVariable(string $name)
    {
        switch (true) {
            case array_key_exists($name, $_ENV):
                return $_ENV[$name];
            case array_key_exists($name, $_SERVER):
                return $_SERVER[$name];
            default:
                $value = getenv($name);

                return $value === false ? null : $value;
        }
    }
318467
protected function env($name, $defaultValue = null)
    {
        $value = getenv($name);

        if (null === $value || false === $value) {
            return $defaultValue;
        }

        return $value;
    }
1111803
public static function choose($environment = null) {
		if (!isset($environment)) {
			if(isset($_ENV["APP_ENV"])) {
				switch($_ENV["APP_ENV"]) {
					case "dev": case "development": default:
						$environment = Environment::DEVELOPMENT; break;
					case "stage":
						$environment = Environment::STAGE; break;
					case "prod": case "production":
						$environment = Environment::PRODUCTION; break;
				}
			} else {
				switch($_SERVER["SERVER_NAME"]) {
					case "localhost":
						$environment = Environment::DEVELOPMENT; break;
					default:
						$environment = Environment::PRODUCTION; break;
				}
			}
		} else {
			$environment = Environment::DEVELOPMENT;
		}
		
		return $environment;
	}
1103109
protected function getDomain(?string $domain = null) : ?string
    {
        $domain = $domain ?? $this->appUrl;

        if ($domain === null) {
            return null;
        }

        return $this->trim(str_replace(['http:', 'https:'], '', $domain), '/');
    }
751740
public function getKey($env, $key)
	{
		$map = $this->getMap($env);

		return isset($map[$key]) ? $map[$key] : null;
	}
862400
public static function getNonSequenceDomain(string $domain) : string {
		if (strpos($domain, '_sequence') !== false) {
			return str_replace('_sequence', '', $domain);
		}
		return $domain;
	}
1208455
protected function getParentEnv()
    {
        if (PHP_VERSION_ID >= 70100) {
            return getenv();
        }
        // In PHP <7.1 there isn't a way to read all of the current environment
        // variables. If PHP is running with a variables_order that includes
        // 'e', then $_ENV should be populated.
        if (!empty($_ENV) && stripos(ini_get('variables_order'), 'e') !== false) {
            return $_ENV;
        }

        // If $_ENV is empty, then we can only use a whitelist of all the
        // variables that we might want to use.
        $candidates = [
            'TERM',
            'TERM_SESSION_ID',
            'TMPDIR',
            'SSH_AGENT_PID',
            'SSH_AUTH_SOCK',
            'PATH',
            'LANG',
            'LC_ALL',
            'LC_CTYPE',
            'PAGER',
            'LESS',
        ];
        $variables = [];
        foreach ($candidates as $name) {
            $variables[$name] = getenv($name);
        }

        return array_filter($variables, function ($value) {
            return $value !== false;
        });
    }
543830
public function getDomainByName($domainName, $default = null)
    {
        if (empty($domainName)) {
            return $default;
        }

        try {
            $result = $this->findOneBy(['domain' => $domainName]);
        } catch (NoResultException $e) {
            $result = $default;
        }

        return $result;
    }
203507
public function getEnvBaseUrl($env)
    {
        switch ($env) {
            case self::ENV_PROD:
                return self::BASE_URL_PROD;
            case self::ENV_STAGE:
                return self::BASE_URL_STAGE;
            case self::ENV_MOCK:
                return null;
        }
    }
839853
public function getCurrentDomain($default = null)
    {
        $currentDomain = PhpServer::getRequestDomain();

        //Use the default site if the requested domain name is an IP address
        $ipValidator = new Ip();
        if ($ipValidator->isValid($currentDomain)) {
            $currentDomain = $default;
        }

        return $currentDomain;
    }
349333
public static function get(string $name): ?string
    {
        if (isset($_ENV[$name])) {
            return $_ENV[$name];
        }

        if (isset($_SERVER[$name])) {
            return $_SERVER[$name];
        }

        $value = \getenv($name);

        return $value === false ? null : $value; // switch getenv default to null
    }
1034852
public function getDomainInfo( $domain ) {
		$domain = $this->normalizeDomain( $domain );
		// Check cache and custom-registered domains
		if ( !isset( $this->domainInfos[ $domain ] ) ) {
			// Default to local domain
			$dir = $this->localBaseDir . '/language/messages/' . $domain;
			if ( !is_dir( $dir ) ) {
				// Domain does not exist
				return false;
			}
			$this->domainInfos[ $domain ] = [
				'dir' => $dir,
			];
		}
		return $this->domainInfos[ $domain ];
	}
441933
public static function env(string $value = null, $fallback = '')
  {
    $val = getenv($value);

    if ($val == null || $val == '') return $fallback;
    return $fallback;
  }
650980
public function getDomain() : ?string 
    {
        if ( ! $this->hasDomain()) {
            $this->setDomain($this->getDefaultDomain());
        }
        return $this->domain;
    }
14183
public static function getVar(string $name, $defaultValue = null)
    {
        $value = getenv($name);
        return $value !== false ? $value : $defaultValue;
    }
702346
public function get(string $key, $default = null)
    {
        $this->autoload();

        if (!\array_key_exists($key, $this->env)) {
            return $default;
        }

        return $this->env[$key];
    }