@param array $env

@return string
439840
protected function buildEnvironmentVariables($env)
    {
        $variables = '';
        foreach ($env as $key => $value) {
            $variables .= $key.'='.$value.' ';
        }

        return trim($variables);
    }
78581
public function get($key, $env = NULL)
    {
        if (!$env) {
            $env = self::$current_env;
        }

        return isset(self::$params[$env][$key]) ? self::$params[$env][$key] : NULL;
    }
340484
public function updateActivity(string $env):Renderer
    {
        $allowed     = $this->get("request")->get("allowed");
        $denied     = $this->get("request")->get("denied");

        if (!in_array($env, array("dev", "prod"))) {
            throw new Server500(new \ArrayObject(array("explain" => "Undefined environment $env", "solution" =>
                "Environment must be [dev or prod]")));
        }

        if (trim($allowed) == "" || trim($denied) == "") {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" => "Error on hosts parameters")));
        }


        $allowed = (object)(explode(";", $allowed));
        $denied = (object)(explode(";", $denied));

        $a = new \stdClass();
        $a->allowed = $allowed;
        $a->denied = $denied;

        JL::put(
            FEnv::get("framework.config").'hosts/hosts.'.$env.'.json',
            json_encode($a, JSON_PRETTY_PRINT)
        );

        return ((new Renderer())->jsonRenderer(array("code" => 200, "msg" => "OK")));
    }
672624
public static function definer(string $env):int
    {
        $base = realpath(__DIR__ . "/../../../../../../")."/";

        define('IUMIO_ENV', $env);
        define('IUMIO_ROOT', $base);

        $current = self::getProtocol()."://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
        $current_temp = substr($current, 0, strpos($current, self::getFileEnv($env)));
        if (strlen($current_temp) > 0) {
            $current = $current_temp;
        }
        if ($current[strlen($current) - 1] == "/") {
            $current = substr($current, 0, (strlen($current) - 1));
        }

        self::__setPaths($base, $env, $current);

        foreach (self::$framework_paths as $one => $val) {
            $container = FrameworkContainer::getInstance();
            $container->set($one, $val);
        }

        return (1);
    }
187500
public function dump(Twig_Environment $env, $context)
    {
        $output = '';

        $count = func_num_args();
        if (2 === $count) {
            $data = [];
            foreach ($context as $key => $value) {
                if (is_object($value)) {
                    if (method_exists($value, 'toArray')) {
                        $data[$key] = $value->toArray();
                    } else {
                        $data[$key] = 'Object (' . get_class($value) . ')';
                    }
                } else {
                    $data[$key] = $value;
                }
            }
            $output .= $this->formatter->formatVar($data);
        } else {
            for ($i = 2; $i < $count; $i++) {
                $output .= $this->formatter->formatVar(func_get_arg($i));
            }
        }

        return '<pre>' . $output . '</pre>';
    }
190858
public static function createFromEnvironment(Environment $env)
    {
        if (is_array($env['slim.files']) && $env->has('slim.files')) {
            return $env['slim.files'];
        } elseif (! empty($_FILES)) {
            return static::parseUploadedFiles($_FILES);
        }

        return [];
    }
462018
static function getConfiguration(array $env): Configuration {
    return new Configuration([
      'commit_sha' => $env['CI_BUILD_REF'] ?? null,
      'service_branch' => $env['CI_BUILD_REF_NAME'] ?? null,
      'service_job_id' => $env['CI_BUILD_ID'] ?? null,
      'service_job_number' => $env['CI_BUILD_NAME'] ?? null,
      'service_name' => 'gitlab-ci'
    ]);
  }
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;
        });
    }
309783
protected function getEnvConfig($name, $env = 'development')
    {
        $default = $this->getArrayDot($this->config, $name, null);
        $env     = $this->getArrayDot($this->config, "env.{$env}.{$name}", null);

        // get merged subtree
        if (is_array($default) && is_array($env)) {
            return array_replace_recursive($default, $env);
        }

        // no default => get env value
        if (!is_null($env)) {
            return $env;
        }

        return $default;
    }
1026453
public function getEnvCmd(string $env = 'WINDWALKER_MODE', string $value = 'dev'): string
    {
        $prefix = $this->environment->getPlatform()->isWin()
            ? 'set'
            : 'export';

        return sprintf('%s %s=%s', $prefix, $env, $value);
    }
120762
public static function createFromEnvironment(Environment $env)
    {
        // Scheme
        $isSecure = $env->get('HTTPS');
        $scheme = (empty($isSecure) || $isSecure === 'off') ? 'http' : 'https';

        // Authority: Username and password
        $username = $env->get('PHP_AUTH_USER', '');
        $password = $env->get('PHP_AUTH_PW', '');

        // Authority: Host and Port
        if ($env->has('HTTP_HOST')) {
            $host = $env->get('HTTP_HOST');
            // set a port default
            $port = null;
        } else {
            $host = $env->get('SERVER_NAME');
            // set a port default
            $port = (int)$env->get('SERVER_PORT', 80);
        }

        if (preg_match('/^(\[[a-fA-F0-9:.]+\])(:\d+)?\z/', $host, $matches)) {
            $host = $matches[1];

            if (isset($matches[2])) {
                $port = (int) substr($matches[2], 1);
            }
        } else {
            $pos = strpos($host, ':');
            if ($pos !== false) {
                $port = (int) substr($host, $pos + 1);
                $host = strstr($host, ':', true);
            }
        }

        // Path
        $requestScriptName = parse_url($env->get('SCRIPT_NAME'), PHP_URL_PATH);
        $requestScriptDir = dirname($requestScriptName);

        // parse_url() requires a full URL. As we don't extract the domain name or scheme,
        // we use a stand-in.
        $requestUri = parse_url('http://example.com' . $env->get('REQUEST_URI'), PHP_URL_PATH);

        $basePath = '';
        $virtualPath = $requestUri;
        if (stripos($requestUri, $requestScriptName) === 0) {
            $basePath = $requestScriptName;
        } elseif ($requestScriptDir !== '/' && stripos($requestUri, $requestScriptDir) === 0) {
            $basePath = $requestScriptDir;
        }

        if ($basePath) {
            $virtualPath = ltrim(substr($requestUri, strlen($basePath)), '/');
        }

        // Query string
        $queryString = $env->get('QUERY_STRING', '');
        if ($queryString === '') {
            $queryString = parse_url('http://example.com' . $env->get('REQUEST_URI'), PHP_URL_QUERY);
        }

        // Fragment
        $fragment = '';

        // Build Uri
        $uri = new static($scheme, $host, $port, $virtualPath, $queryString, $fragment, $username, $password);
        if ($basePath) {
            $uri = $uri->withBasePath($basePath);
        }

        return $uri;
    }
1372431
protected function buildSearchDirs(/*# string */ $env)/*# : array */
    {
        $path = $this->root_dir;
        $part = preg_split(
            '/[\/\\\]/',
            trim($env, '/\\'),
            0,
            \PREG_SPLIT_NO_EMPTY
        );
        $subdirs = [$path];
        foreach ($part as $dir) {
            $path .= $dir . \DIRECTORY_SEPARATOR;
            if (false === file_exists($path)) {
                trigger_error(
                    Message::get(Message::CONFIG_ENV_UNKNOWN, $env),
                    \E_USER_WARNING
                );
                break;
            }
            $subdirs[] = $path;
        }
        return $subdirs;
    }
956151
static function fromEnvironment(array $env = null): self {
    if (!is_array($env)) $env = $_ENV ?: $_SERVER;
    $config = new static;

    // Standard.
    $serviceName = $env['CI_NAME'] ?? '';
    if (mb_strlen($serviceName)) $config['service_name'] = $serviceName;

    if (isset($env['CI_BRANCH'])) $config['service_branch'] = $env['CI_BRANCH'];
    if (isset($env['CI_BUILD_NUMBER'])) $config['service_number'] = $env['CI_BUILD_NUMBER'];
    if (isset($env['CI_BUILD_URL'])) $config['service_build_url'] = $env['CI_BUILD_URL'];
    if (isset($env['CI_COMMIT'])) $config['commit_sha'] = $env['CI_COMMIT'];
    if (isset($env['CI_JOB_ID'])) $config['service_job_id'] = $env['CI_JOB_ID'];

    if (isset($env['CI_PULL_REQUEST']) && preg_match('/(\d+)$/', $env['CI_PULL_REQUEST'], $matches)) {
      if (count($matches) >= 2) $config['service_pull_request'] = $matches[1];
    }

    // Coveralls.
    if (isset($env['COVERALLS_REPO_TOKEN']) || isset($env['COVERALLS_TOKEN']))
      $config['repo_token'] = $env['COVERALLS_REPO_TOKEN'] ?? $env['COVERALLS_TOKEN'];

    if (isset($env['COVERALLS_COMMIT_SHA'])) $config['commit_sha'] = $env['COVERALLS_COMMIT_SHA'];
    if (isset($env['COVERALLS_PARALLEL'])) $config['parallel'] = $env['COVERALLS_PARALLEL'];
    if (isset($env['COVERALLS_RUN_AT'])) $config['run_at'] = $env['COVERALLS_RUN_AT'];
    if (isset($env['COVERALLS_SERVICE_BRANCH'])) $config['service_branch'] = $env['COVERALLS_SERVICE_BRANCH'];
    if (isset($env['COVERALLS_SERVICE_JOB_ID'])) $config['service_job_id'] = $env['COVERALLS_SERVICE_JOB_ID'];
    if (isset($env['COVERALLS_SERVICE_NAME'])) $config['service_name'] = $env['COVERALLS_SERVICE_NAME'];

    // Git.
    if (isset($env['GIT_AUTHOR_EMAIL'])) $config['git_author_email'] = $env['GIT_AUTHOR_EMAIL'];
    if (isset($env['GIT_AUTHOR_NAME'])) $config['git_author_name'] = $env['GIT_AUTHOR_NAME'];
    if (isset($env['GIT_BRANCH'])) $config['service_branch'] = $env['GIT_BRANCH'];
    if (isset($env['GIT_COMMITTER_EMAIL'])) $config['git_committer_email'] = $env['GIT_COMMITTER_EMAIL'];
    if (isset($env['GIT_COMMITTER_NAME'])) $config['git_committer_name'] = $env['GIT_COMMITTER_NAME'];
    if (isset($env['GIT_ID'])) $config['commit_sha'] = $env['GIT_ID'];
    if (isset($env['GIT_MESSAGE'])) $config['git_message'] = $env['GIT_MESSAGE'];

    // CI services.
    if (isset($env['TRAVIS'])) {
      $config->merge(TravisCI::getConfiguration($env));
      if (mb_strlen($serviceName) && $serviceName != 'travis-ci') $config['service_name'] = $serviceName;
    }
    else if (isset($env['APPVEYOR'])) $config->merge(AppVeyor::getConfiguration($env));
    else if (isset($env['CIRCLECI'])) $config->merge(CircleCI::getConfiguration($env));
    else if ($serviceName == 'codeship') $config->merge(Codeship::getConfiguration($env));
    else if (isset($env['GITLAB_CI'])) $config->merge(GitLabCI::getConfiguration($env));
    else if (isset($env['JENKINS_URL'])) $config->merge(Jenkins::getConfiguration($env));
    else if (isset($env['SEMAPHORE'])) $config->merge(Semaphore::getConfiguration($env));
    else if (isset($env['SURF_SHA1'])) $config->merge(Surf::getConfiguration($env));
    else if (isset($env['TDDIUM'])) $config->merge(SolanoCI::getConfiguration($env));
    else if (isset($env['WERCKER'])) $config->merge(Wercker::getConfiguration($env));

    return $config;
  }
855584
public function renderInline($src, $env=null)
    {
        $env = is_object($env) ? $env : new \stdClass();

        $tokens = $this->parseInline($src, $env);
        return $this->renderer->render($tokens, $this->options, $env);
    }
202572
protected function getPantheonSiteEnv($env = '') {
    $site = getenv('TERMINUS_SITE');

    if (!$env) {
      $env = getenv('TERMINUS_ENV');
    }

    return join('.', [$site, $env]);
  }
653824
public function to($env, $data, $key = null, $array = false)
	{
		$this->validateEnvironment($env);

		if (!is_array($data) && empty($data) && $data !== false) {
			return null;
		}

		// Handle arrays by recursion
		if ($array) {
			$map = function ($data) use ($env, $key) {
				return $this->to($env, $data, $key);
			};

			return array_map($map, $data);
		}

		// Handle keys
		if (!is_null($key)) {
			if (!$def = $this->getDefinition($env, $key)) {
				throw new \InvalidArgumentException('Unknown key: ' . $key);
			}

			return $this->parseDefinitionValue($def, $data);
		}

		// Transform a data set
		$method_before = 'before' . ucfirst($env);
		$method_after  = 'after' . ucfirst($env);
		$ret           = [];

		$data = $this->$method_before($data);
		foreach ($data as $key => $value) {
			if ($def = $this->getDefinition($env, $key)) {
				$ret[$def[self::DEFINITION_KEY]] = $this->parseDefinitionValue($def, $value);
			} elseif (array_key_exists($key, $this->virtual_fields)) {
				$ret[$key] = $value;
			}
		}
		$ret = $this->$method_after($ret);

		return $ret;
	}
445417
public function load($env)
    {
        try {
            return $this->files->getRequire($this->path($env));
        } catch (Exception $e) {
            return false;
        }
    }