DataSift\Storyplayer\OsLib\Base_Unix::determineIpAddress PHP Method

determineIpAddress() public method

public determineIpAddress ( HostDetails $hostDetails, DataSift\Storyplayer\HostLib\SupportedHost $host ) : string
$hostDetails HostDetails
$host DataSift\Storyplayer\HostLib\SupportedHost
return string
    public function determineIpAddress($hostDetails, SupportedHost $host)
    {
        // what are we doing?
        $log = usingLog()->startAction("query " . basename(__CLASS__) . " for IP address");
        // how do we do this?
        if (isset($hostDetails->hostname)) {
            $ipAddress = gethostbyname($hostDetails->hostname);
            if ($ipAddress != $hostDetails->hostname) {
                $log->endAction(["IP address is", $ipAddress]);
                return $ipAddress;
            }
        }
        // if we get here, we do not know what the IP address is
        $msg = "could not determine IP address";
        $log->endAction($msg);
        throw new E5xx_ActionFailed(__METHOD__, $msg);
    }