Get api end point.
@return string server url
@throws RuntimeException if no server available
166765
protected function getApiEndpoint()
    {
        $servers = array();
        if ($this->options['sandbox']) {
            $servers[] = self::SANDBOX_SERVER;
        } else {
            $servers = array(self::MAIN_SERVER, self::BACKUP_SERVER);
        }

        foreach ($servers as $server) {
            $doc = new \DOMDocument();
            $doc->loadHTMLFile('https://'. $server . "/load.html");

            $element = $doc->getElementById('server_status');
            if ($element && 'OK' == $element->textContent) {
                return $server;
            }
        }

        throw new RuntimeException('No server available.');
    }
920598
protected function recv() {
		if (($line = fgets($this->handle)) && 
			($line = trim($line))) {
			if ($this->logger) {
				$this->logger
					->onReceive($line);
			}
			
			return $line;
		}
		
		throw new \RuntimeException(
			"failed to receive data from {$this->server}");
	}
1287475
public function getUrl()
    {
        $this->validateMethod();

        $apiVersion = UrlManipulator::forceSlashPrefix($this->apiVersion);
        $endpoint   = UrlManipulator::forceSlashPrefix($this->getEndpoint());

        $url = $apiVersion.$endpoint;

        if ($this->getMethod() !== 'POST') {
            $params = $this->getParams();
            $url = UrlManipulator::appendParamsToUrl($url, $params);
        }

        return $url;
    }
1039589
public function getEndpoint()
    {
        if (is_null($this->endpoint)) {
            $this->endpoint = str_replace('\\', '', snake_case(str_plural(class_basename($this))));
        }

        return $this->endpoint;
    }
1257819
public function getJsBundleUrl()
    {
        $url = $this->getJsCacheUrl();

        if (!$url) {
            $url = $this->getJsCachePath();

            if (!$this->isRelativePath($url)) {
                throw new \RuntimeException('If you do not provide a js cache url, js cache path must be a relative local path...');
            }

            $url = '/' . str_replace(DIRECTORY_SEPARATOR, '/', $url);
        }

        $name = $this->getName();

        if (null === $name) {
            $name = sprintf('bundle_%s', $this->getJsFileList()->getHash());
        } elseif (strpos($name, '%s') !== false) {
            $name = sprintf($name, $this->getJsFileList()->getHash());
        }

        return sprintf(
            "%s/%s.js",
            $url,
            $name
        );
    }
431069
public function getEndpoint()
    {
        $basePath = $this->app['config']->get('api.base_path', self::DEFAULT_BASE_PATH);
        $basePath = $this->stripTrailingSlash($basePath);

        // determine the base URL for the API,
        // i.e. https://api.example.com/v1
        $urlBase = $this->app['config']->get('api.url');
        if ($urlBase) {
            $urlBase = $this->stripTrailingSlash($urlBase);
        } else {
            // no base URL was defined so we're going to generate one
            $urlBase = $this->app['base_url'];
            $urlBase = $this->stripTrailingSlash($urlBase).$basePath;
        }

        // get the requested path, strip any trailing '/'
        $path = $this->stripTrailingSlash($this->request->path());

        // strip out the base path (i.e. /api/v1) from the
        // requested path
        if ($basePath) {
            $path = str_replace($basePath, '', $path);
        }

        return $urlBase.$path;
    }
467074
public function getAPIEndpoint($uri = false)
    {
        $endpoint = $this->getBase() . '/' . $this->getVersion() . '/';

        if ($uri) {
            $endpoint .= $uri;
        }

        return $endpoint;
    }
161179
public function getQueryString()
    {
        $query = parent::getQueryString();
        if ($query) {
            $query .= '&';
        }

        if (!defined('REQUEST_TOKEN')) {
            throw new \RuntimeException('Request token not defined - can not append to query string.');
        }

        $query .= 'rt=' . REQUEST_TOKEN;

        return $query;
    }
79196
public function url() {
		$url = $this->client->endpoint() . $this->resource . '.json';
		if (in_array($this->method, ['GET', 'DELETE']) && $this->params !== null) {
			$url .= '?' . http_build_query($this->params);
		}
		return $url;
	}
917088
public function getEndpointUrl()
    {
        $defaultUrl = $this->getTestMode() === false
            ? $this->endpointLive
            : $this->endpointSandbox;

        return $this->parameters->get('endpointUrl', $defaultUrl);
    }
631746
private function get_api_url() {
		if ( empty( $this->api_url ) ) {
			$this->api_url = trailingslashit( $this->glotpress_url ) . 'api/projects/' . $this->project_slug;
		}

		return $this->api_url;
	}
63223
public static function current():string
    {
        if (php_sapi_name() === 'cli') {
            throw new \RuntimeException('function Url::current can not run in the cli.');
        }
        $protocol = (!empty($_SERVER['HTTPS'])
            && $_SERVER['HTTPS'] !== 'off'
            || $_SERVER['SERVER_PORT'] === 443) ? 'https://' : 'http://';
        return $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    }
1071478
public function getRequest()
    {
        if (!$this->getContainer()->has(ServerRequestInterface::class)) {
            $this->getContainer()->share(ServerRequestInterface::class,function(){
                $beforeIndexPosition = strpos($_SERVER['PHP_SELF'],'/index.php');
                /**
                 * If there is some string before /index.php then remove this string from REQUEST_URI
                 */
                if(false !== $beforeIndexPosition && $beforeIndexPosition > 0){
                    $scriptUrl =  substr($_SERVER['PHP_SELF'],0,$beforeIndexPosition);
                    $_SERVER['REQUEST_URI'] = str_replace(['/index.php',$scriptUrl],'',$_SERVER['REQUEST_URI']);
                }
                return  ServerRequestFactory::fromGlobals()->withHeader('content-type', $this->getContentType());
            });
        }

        /** @var ServerRequestInterface $request */
        $request = $this->validateContract($this->getContainer()->get(ServerRequestInterface::class),
            ServerRequestInterface::class);
        return $request;
    }
144126
public static function getCurrentURL(): Url
    {
        if (static::$currentUrl instanceof Url) {
            return static::$currentUrl;
        }

        if (Application::isCli()) {
            throw new ApplicationException('Can not get current URL while running in CLI mode; URL doesn\'t exist in CLI mode');
        }

        static::$currentUrl = new Url(static::getDomainWithSchema() . static::getUri());
        return static::$currentUrl;
    }
1155866
public function getEndpoint()
    {
        $endpoint = $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;

        return $endpoint . $this->getAccountNumber() . '/rs/authService';
    }
684382
public function getBody()
    {
        if ($this->isAbstract() === true) {
            throw new RuntimeException('Can not get body of an abstract method');
        }

        $fileName = $this->getDeclaringClass()->getFileName();
        if ($fileName === false) {
            throw new RuntimeException('Can not get body of a method belonging to an internal class.');
        }

        $lines = file($fileName, FILE_IGNORE_NEW_LINES);
        $lines = array_slice($lines, $this->getStartLine() - 1, ($this->getEndLine() - $this->getStartLine() + 1),
            true);
        $lines = implode("\n", $lines);

        $firstBracketPos = strpos($lines, '{');
        $lastBracketPost = strrpos($lines, '}');
        $body = substr($lines, $firstBracketPos + 1, $lastBracketPost - $firstBracketPos - 1);

        return trim(rtrim($body), "\n\r");
    }
30793
protected function getServerRuntime()
    {
        $filename = $this->option('filename') ?? storage_path('framework/server.runtime');

        if (! file_exists($filename)) {
            return null;
        }

        return json_decode(file_get_contents($filename), true);
    }