$args * @return string */ private static function buildUrl(string $url, string $path, array $args): string { $url .= $path; if(!empty($args)) { $url .= str_contains($url, '?') ? '&' : '?'; $url .= http_build_query($args, encoding_type: PHP_QUERY_RFC3986); } return $url; } /** * Retrieves the API base URL. * * @param string $path Path to append to the URL. * @param array $args Query arguments to append to the URL. * @return string */ public function getApiUrl(string $path = '', array $args = []): string { return self::buildUrl($this->apiUrl, $path, $args); } /** * Retrieves the ID service base URL. * * @param string $path Path to append to the URL. * @param array $args Query arguments to append to the URL. * @return string */ public function getIdUrl(string $path = '', array $args = []): string { return self::buildUrl($this->idUrl, $path, $args); } /** * Creates an instance with the production URLs preset. * * @return FlashiiUrls */ public static function production(): self { return new static( self::PROD_API_URL, self::PROD_ID_URL ); } }