withHost(static::API_SUBDOMAIN . $base->getHost()); } /** * @return Uri */ public static function getCurrent(): Uri { if (static::$current) { return static::$current; } $scheme = $_SERVER['REQUEST_SCHEME']; $host = $_SERVER['HTTP_HOST']; $requestUri = $_SERVER['REQUEST_URI']; return static::$current = new Uri("$scheme://$host$requestUri"); } /** * @return bool */ public static function isApi(): bool { $currentHost = static::getCurrent()->getHost(); $apiHost = static::getApi()->getHost(); return $currentHost === $apiHost; } /** * @return string */ public static function getLastPathPart(): string { $path = static::getCurrent()->getPath(); $parts = explode("/", $path); do { $part = trim(array_pop($parts)); } while ($part === "" && count($parts) > 0); return $part; } }