@param array $globalConstraints

@return string
2846
public function compileRegex(array $globalConstraints): string
    {
        $url = $this->extractInlineContraints($this->url, 'constraints');

        $regex = \preg_replace('/\{(\w+?)\}/', '(?P<$1>[^/]++)', $url);

        $constraints = \array_merge($globalConstraints, $this->constraints);

        foreach ($this->optionalsParameters as $key => $defaultValue) {
            $regex = \str_replace('(?P<' . $key . '>[^/]++)', '?(?P<' . $key . '>[^/]++)?', $regex);
        }

        foreach ($constraints as $id => $regexRule) {
            $regex = \str_replace('<' . $id . '>[^/]++', '<' . $id . '>' . $regexRule, $regex);
        }

        return $regex;
    }
729036
protected function containsForeignConstraint(array $properties)
    {
        return Helpers::isKeyExists($properties, 'foreign-constraint')
        && is_array($properties['foreign-constraint'])
        && Helpers::isKeyExists($properties['foreign-constraint'], 'field', 'references', 'on');
    }
1075123
public function addGlobalConfigPath(string ...$globalConfigPaths): ApplicationBuilder
    {
        foreach ($globalConfigPaths as $globalConfigPath) {
            $this->globalConfigPaths[] = $globalConfigPath;
        }

        return $this;
    }
792717
public static function parseForHeadersFromGlobal(array $globals = null) : array
    {
        $globals = $globals === null ? $_SERVER : $globals;
        $globals = self::determineHeaderAuthorization($globals);
        /**
         * Special HTTP headers that do not have the "HTTP_" prefix
         *
         * @var array
         */
        $special = [
            'CONTENT_TYPE'    => 1,
            'CONTENT_LENGTH'  => 1,
            'PHP_AUTH_USER'   => 1,
            'PHP_AUTH_PW'     => 1,
            'PHP_AUTH_DIGEST' => 1,
            'AUTH_TYPE'       => 1,
        ];

        $data = [];
        foreach ($globals as $key => $value) {
            $key = strtoupper($key);
            if (isset($special[$key]) || strpos($key, 'HTTP_') === 0) {
                if ($key !== 'HTTP_CONTENT_LENGTH') {
                    $key        = self::reconstructOriginalKey($key);
                    $data[$key] = $value;
                }
            }
        }

        return $data;
    }
251563
public function getConstraint($fieldName, $constraintName)
    {
        if (isset($this->constraints[$fieldName][$constraintName])) {
            return $this->constraints[$fieldName][$constraintName];
        }
    }
479061
protected function _getConstraintClass($type)
    {
        $class = null;
        foreach ($this->_constraintExpressions as $className => $exp) {
            if (preg_match("/{$exp}/i", $type)) {
                $class = $className;
                break;
            }
        }
        return $class;
    }
570467
private function getRuntimeParameterConstraints(
        ParameterDefinition $parameterDefinition,
        $parameterValue,
        array $allParameterValues
    ): Generator {
        foreach ($parameterDefinition->getConstraints() as $constraint) {
            if ($constraint instanceof Closure) {
                $constraint = $constraint($parameterValue, $allParameterValues, $parameterDefinition);
            }

            if ($constraint instanceof Constraint) {
                yield $constraint;
            }
        }
    }
86171
private function parseGlobals(array $globals) : array
    {
        list(, $method, $uri) = $globals['argv'];
        $urlQuery = parse_url($uri, PHP_URL_QUERY);
        $urlPath =  parse_url($uri, PHP_URL_PATH);
        $query = [];
        if ($urlQuery) {
            parse_str($urlQuery, $query);
        }
        $server = [
            'REQUEST_METHOD' => strtoupper($method),
            'REQUEST_URI' => $urlPath
        ];

        return [$method, $query, $server];
    }
1259502
public function isSameHost(string $host, array $globalConstraints): bool
    {
        if ($this->host === null) {
            return true;
        }

        if (\mb_strpos($this->host, '{') === false) {
            return $this->host === $host;
        }

        $regex = $this->extractInlineContraints($this->host, 'hostConstraints');

        $regex = \preg_replace('/\{(\w+?)\}/', '(?P<$1>[^.]++)', $regex);

        $constraints = \array_merge($globalConstraints, $this->hostConstraints);
        foreach ($constraints as $id => $regexRule) {
            $regex = \str_replace('<' . $id . '>[^.]++', '<' . $id . '>' . $regexRule, $regex);
        }
        $pattern = '#^' . $regex . '$#s';
        $matches = [];

        if (\preg_match($pattern, $host, $matches)) {
            \array_shift($matches);
            $this->saveHostParameters($matches);

            return true;
        }

        return false;
    }
1059686
private function getConstraint(Closure $callback = null)
    {
        $constraint = new Constraint(clone $this);

        if ($callback !== null) {
            $callback($constraint);
        }

        return $constraint;
    }
1009633
public static function createFromGlobals(array $globals = null) : UriInterface
    {
        $globals = $globals === null
            ? static::fixSchemeProxyFromGlobals($_SERVER)
            : $globals;

        // Scheme
        $isSecure = isset($globals['HTTPS']) ? $globals['HTTPS'] : null;
        $scheme = (empty($isSecure) || $isSecure === 'off') ? 'http' : 'https';
        // Authority: Username and password
        $username = isset($globals['PHP_AUTH_USER']) ? $globals['PHP_AUTH_USER'] : null;
        $password = isset($globals['PHP_AUTH_PW']) ? $globals['PHP_AUTH_PW'] : null;
        // Authority: Host
        if (isset($globals['HTTP_HOST'])) {
            $host = $globals['HTTP_HOST'];
        } elseif (isset($globals['SERVER_NAME'])) {
            $host = $globals['SERVER_NAME'];
        } else {
            $host = 'localhost';
        }

        // Authority: Port
        $port = (int) (isset($globals['SERVER_PORT']) ? $globals['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);
            }
        }

        $globalsRequestUri = (isset($globals['REQUEST_URI']) ? $globals['REQUEST_URI']:'');
        // 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' . $globalsRequestUri, PHP_URL_PATH);
        $requestUri = rawurldecode((string) $requestUri);

        // Query string
        $queryString = isset($globals['QUERY_STRING']) ? $globals['QUERY_STRING'] :'';
        if ($queryString === '') {
            $queryString = parse_url('http://example.com' . $globalsRequestUri, PHP_URL_QUERY);
        }

        $uri = "{$scheme}://{$host}:{$port}{$requestUri}";
        if ($queryString !== '') {
            $uri .= "?{$queryString}";
        }

        // Build Uri
        $uri = new static($uri, true);
        if ($username !== null) {
            $uri = $uri->withUserInfo($username, $password);
        }
        return $uri;
    }
628860
private function isArrayConstraint(Constraint $constraint): bool
    {
        return $constraint instanceof Assert\All // << Applied only on array
            || ($constraint instanceof Assert\Choice
                && true === $constraint->multiple // << expect an array multiple choices
            );
    }
863205
public function matchConstraints(array $constraints)
    {
        foreach ($constraints as $constraint) {
            $result = true;
            if (isset($constraints['host_match'])) {
                $result = $result && $this->hostMatch($constraints['host_match']);
            }

            if (isset($constraints['host'])) {
                $result = $result && $this->hostEqual($constraints['host']);
            }

            if (isset($constraints['request_method'])) {
                $result = $result && $this->requestMethodEqual($constraints['request_method']);
            }

            if (isset($constraints['path_match'])) {
                $result = $result && $this->pathMatch($constraints['path_match']);
            }

            if (isset($constraints['path'])) {
                $result = $result && $this->pathEqual($constraints['path']);
            }

            // If it matches all constraints, we simply return true and skip other constraints
            if ($result) {
                return true;
            }
            // try next one
        }

        return false;
    }
450427
public function getSchemaUniqueConstraints($conn = null)
    {
        $command = $this->invoke('neo.get_constraints_command', $conn);
        $httpResponse = $command->execute();

        $responseO = $this->handleHttpResponse($httpResponse);
        $response = $responseO->getBody();
        $constraints = [];
        foreach ($response as $constraint) {
            foreach ($constraint['property_keys'] as $key) {
                $constraints[] = new UniqueConstraint($constraint['label'], $key);
            }
        }

        return $constraints;
    }
462710
public function policyConstraints(): Ext\PolicyConstraintsExtension
    {
        /** @var Extension\PolicyConstraintsExtension $policyConstraints */
        $policyConstraints = $this->get(Ext\Extension::OID_POLICY_CONSTRAINTS);
        return $policyConstraints;
    }
391644
protected function parseConstraints(array $constraints)
    {
        $parsedConstraints = [];

        foreach ($constraints as $key=>$keyConstraints) {
            $parsedConstraints[$key] = $this->parseConstraint($keyConstraints);
        }

        return $parsedConstraints;
    }
709443
public function getUniqueConstraints($conn = null)
    {
        $command = $this->invoke('neo.get_constraints_command', $conn);
        $httpResponse = $command->execute();

        $responseO = $this->handleHttpResponse($httpResponse);
        $response = $responseO->getBody();
        $constraints = [];
        foreach ($response as $constraint) {
            foreach ($constraint['property_keys'] as $key) {
                $constraints[$constraint['label']][] = $key;
            }
        }
        if ($responseO instanceof \GraphAware\NeoClient\Formatter\Response) {
            $msg = new PsrResponse(200, array(), json_encode($constraints));
            return new \GraphAware\NeoClient\Formatter\Response($msg);
        }

        $responseO->setBody($constraints);

        return $responseO;
    }