get token, logged and role value from environment
@access public
@param $in    array : array which contain the value
@param $array array : "path" to the value in $in
@return mixed
@since 3.0
@package Gcs\Framework\Core\Router
340304
protected function _setFirewallConfigArray($in, $array) {
        if (isset($in['' . $array[0] . ''])) {
            $to = $in['' . $array[0] . ''];
            array_splice($array, 0, 1);

            foreach ($array as $value) {
                if (isset($to['' . $value . ''])) {
                    $to = $to['' . $value . ''];
                }
                else {
                    return false;
                }
            }
        }
        else {
            return false;
        }

        return $to;
    }
1144450
protected function tokenInfo2Fields(array $tokenInfo)
    {
        $fields = array();
        foreach ($tokenInfo as $variableName => $variableInfo) {
            $fields["token-$variableName"] = $this->get1TokenField($variableName, $variableInfo);
        }
        return $fields;
    }
252198
public static function fromArray($array)
    {
        $isRemote     = isset($array['remote']) || isset($array['remote_value']);
        $isRemoteProp = $isRemote && !isset($array['remote_value']);

        if ($isRemote) {
            if ($isRemoteProp) {
                $value = $array['remote'];
            } else {
                $value = $array['remote_value'];
            }
            $property = $array['local'];
        } else {
            $value    = $array['value'];
            $property = $array['property'];
        }

        if (!(isset($value, $property))) {
            throw new DcGeneralInvalidArgumentException('Invalid filter array provided  ' . \var_export($array, true));
        }

        return new static($property, $value, $isRemote, $isRemoteProp);
    }
1143103
public static function getByPath(string $path, ?array $array = null, $delimiter = '.')
    {
        // path of nothing? interest
        if (!Any::isArray($array) || count($array) < 1 || !Any::isStr($path) || Str::likeEmpty($path)) {
            return null;
        }

        // c'mon man, what the f*ck are you doing? ))
        if (!Str::contains($delimiter, $path)) {
            return $array[$path];
        }

        $output = $array;
        $pathArray = explode($delimiter, $path);
        foreach ($pathArray as $key) {
            if (!Any::isArray($output) || !array_key_exists($key, $output)) {
                return null;
            }

            $output = $output[$key];
        }
        return $output;
    }
171384
public static function get(array $array, $key = null, $default = null)
    {
        if (is_null($key)) {
            return;
        }

        if (isset($array[$key])) {
            return $array[$key];
        }

        foreach (explode('.', $key) as $token) {
            if (! is_array($array) or ! array_key_exists($token, $array)) {
                return $default;
            }

            $array = $array[$token];
        }

        return $array;
    }
570472
private function filterUniqueRole($array)
    {
        $arrayRewrite = array();
        foreach ($array as $key => $parent)
        {
            foreach ($parent as $role)
            {
                if (!isset($arrayRewrite[$key]) || !in_array($role, $arrayRewrite[$key]))
                {
                    $arrayRewrite[$key][] = $role;
                }
            }
        }
        return $arrayRewrite;
    }
915423
public static function tryGetKeysChainValue($array)
    {
        $arguments = func_get_args();
        $numArguments = func_num_args();

        $currentArray = $array;
        for ($i = 1; $i < $numArguments; ++$i) {
            if (is_array($currentArray)) {
                if (array_key_exists($arguments[$i], $currentArray)) {
                    $currentArray = $currentArray[$arguments[$i]];
                } else {
                    return null;
                }
            } else {
                return null;
            }
        }

        return $currentArray;
    }
119724
public static function sGet($array, $key, $default = null)
    {
        $value = self::get($array, $key);
        return !empty($value) ? $value : $default;
    }
604572
public static function getValueAtIndex($array, $index)
    {
        $value = null;

        if (abs((int) $index) == self::LAST_INDEX) {
            $index == self::LAST_INDEX ? end($array) : reset($array);
            $value = current($array);
        } elseif (isset($array[$index])) {
            $value = $array[$index];
        }

        return $value;
    }
1219179
private function getSpecifiedEnvironmentRoles(array $roles)
    {
        $environmentRoles = [];
        $project = $this->getSelectedProject();
        $environments = $this->api()->getEnvironments($project);
        foreach ($roles as $role) {
            if (strpos($role, ':') === false) {
                continue;
            }
            list($id, $role) = explode(':', $role, 2);
            $role = $this->validateEnvironmentRole($role);
            // Match environment IDs by wildcard.
            if (strpos($id, '%') !== false) {
                $pattern = '/^' . str_replace('%', '.*', preg_quote($id)) . '$/';
                $matched = preg_grep($pattern, array_keys($environments));
                if (empty($matched)) {
                    throw new InvalidArgumentException('No environment IDs match: ' . $id);
                }
                foreach ($matched as $environmentId) {
                    $environmentRoles[$environmentId] = $role;
                }
                continue;
            }
            if (!$this->api()->getEnvironment($id, $project)) {
                throw new InvalidArgumentException('Environment not found: ' . $id);
            }
            $environmentRoles[$id] = $role;
        }

        return $environmentRoles;
    }
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;
	}
128881
public function getValue(
        array $array,
        string $key,
        $defaultValue = null,
        bool $splitKey = true,
        string $checkedValue = null
    ) {
        if (empty($array) || (empty($key) && ! $key === 0)) {
            return $defaultValue;
        }

        if ( ! $splitKey && array_key_exists($key, $array)) {
            return $array[ $key ];
        }

        $keys = $splitKey ? preg_split('/:/', $key) : [$key];

        if ( ! empty($keys)) {
            $firstKey = trim(array_shift($keys));

            if ($checkedValue && count($keys) === 0) {
                if (array_key_exists($firstKey, $array) && $array[ $firstKey ] == $checkedValue) {
                    return $array;
                }

                foreach ($array as $arrayItem) {
                    if (is_array($arrayItem) && array_key_exists($firstKey, $arrayItem) &&
                        $arrayItem[ $firstKey ] == $checkedValue) {
                        return $arrayItem;
                    }
                }
            } else if (preg_match('/^\[([\w_-]+)=(.+)\]$/', $firstKey, $matches)) {
                $valueKey = array_key_exists(1, $matches) ? $matches[ 1 ] : null;
                $valueValue = array_key_exists(2, $matches) ? $matches[ 2 ] : null;

                foreach ($array as $value) {
                    if (is_array($value)) {
                        $valueKeys = array_keys($value);

                        foreach ($valueKeys as $nextValueKey) {
                            if (strcasecmp($nextValueKey, $valueKey) == 0 && array_key_exists($nextValueKey, $value) &&
                                $value[ $nextValueKey ] == $valueValue) {
                                if (count($keys) > 0) {
                                    return $this->getValue($value, join(':', $keys), $defaultValue);
                                } else {
                                    return $value;
                                }
                            }
                        }
                    }
                }
            } else {
                $arrayKeys = array_keys($array);

                foreach ($arrayKeys as $arrayKey) {
                    if (strcasecmp($arrayKey, $firstKey) == 0) {
                        $result = array_key_exists($arrayKey, $array) ? $array[ $arrayKey ] : null;

                        if (is_array($result) && count($keys) > 0) {
                            return $this->getValue($result, join(':', $keys), $defaultValue, $splitKey, $checkedValue);
                        } else if (count($keys) === 0) {
                            return $result;
                        } else {
                            return $defaultValue;
                        }
                    }
                }
            }
        }

        return $defaultValue;
    }
549591
public static function array_get($arr, $path, $default=null) {
		if(!is_array($path))
			$path = [$path];
		foreach($path as $key) {
			if(!isset($arr[$key]))
				return $default;
			else
				$arr = $arr[$key];
		}
		return $arr;
	}
677364
protected function getIn($key, $in)
    {
        $keys = explode($this->getSeparator(), $key, 2);
        if (count($keys) <= 0) {
            return '';
        } else 
            if (isset($in[$keys[0]])) {
                if (count($keys) >= 2) {
                    return $this->getIn($keys[1], $in[$keys[0]]);
                } else {
                    return $in[$keys[0]];
                }
            } else {
                return '';
            }
    }
33
public function getInArray($name, array $array)
    {
        $value = $this->get($name);
        return in_array($value, $array) ? $value : $array[key($array)];
    }
438840
protected function getValueOfToken(array $token)
    {
        switch ($token[Lexer::TYPE]) {
            case Lexer::T_QUOTED_STRING:
                return substr($token[Lexer::VALUE], 1, -1);

            case Lexer::T_NUMBER:
                return (float)$token[Lexer::VALUE];

            case Lexer::T_TRUE:
                return true;

            case Lexer::T_FALSE:
                return false;

            case Lexer::T_NULL:
                return null;
        }

        return null;
    }
1138642
private function saveEnv($array)
    {
        if (is_array($array)) {
            $newArray = [];
            $i = 0;
            foreach ($array as $env) {

                if (preg_match('/\s/', $env['value']) > 0 && (strpos($env['value'], '"') > 0 && strpos($env['value'], '"', -0) > 0)) {
                    $env['value'] = '"'.$env['value'].'"';
                }
                $newArray[$i] = $env['key']."=".$env['value'];
                $i++;
            }
            $newArray = implode("\n", $newArray);
            file_put_contents($this->env, $newArray);
            return true;
        }
        return false;
    }