Request::getUri(): string

In this article

Gets the request URI.

Description

For GET requests with array data, appends the data as query parameters.

Return

string The URI.

Source

public function getUri(): string
{
    // If GET request with data, append as query parameters
    if ($this->method === HttpMethodEnum::GET() && $this->data !== null && !empty($this->data)) {
        $separator = str_contains($this->uri, '?') ? '&' : '?';
        return $this->uri . $separator . http_build_query($this->data);
    }
    return $this->uri;
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.