Airship\Engine\Continuum\Channel::getURL PHP Method

getURL() public method

Get a random URL
public getURL ( ) : string
return string
    public function getURL() : string
    {
        $state = State::instance();
        $candidates = [];
        if ($state->universal['tor-only']) {
            // Prioritize Tor Hidden Services
            foreach ($this->urls as $url) {
                if (\Airship\isOnionUrl($url)) {
                    $candidates[] = $url;
                }
            }
            // If we had any .onions, we will only use those.
            // Otherwise, use non-Tor URLs over Tor.
            if (empty($candidates)) {
                $candidates = $this->urls;
            }
        } else {
            $candidates = $this->urls;
        }
        $max = \count($candidates) - 1;
        return $candidates[\random_int(0, $max)];
    }