AbstractApiProvider::url( string $path = '' ): string

In this article

Constructs a full URL by combining the base URL with an optional path.

Description

This method ensures proper URL construction by:

  • Using the provider’s base URL
  • Trimming leading slashes from the path to prevent double-slashes
  • Joining the base URL and path with a single forward slash

Parameters

$pathstringoptional
Optional path to append to the base URL.

Default:''

Return

string The complete URL.

Source

public static function url(string $path = ''): string
{
    if ($path === '') {
        return static::baseUrl();
    }
    return static::baseUrl() . '/' . ltrim($path, '/');
}

Changelog

VersionDescription
0.2.0Introduced.

User Contributed Notes

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