duncan3dc\Sonos\Network::getControllerByIp PHP Метод

getControllerByIp() публичный Метод

Get the coordinator for the specified ip address.
public getControllerByIp ( string $ip ) : Controller | null
$ip string The ip address of the speaker
Результат Controller | null
    public function getControllerByIp($ip)
    {
        $speakers = $this->getSpeakers();
        if (!array_key_exists($ip, $speakers)) {
            throw new \InvalidArgumentException("No speaker found for the IP address '{$ip}'");
        }
        $group = $speakers[$ip]->getGroup();
        foreach ($this->getControllers() as $controller) {
            if ($controller->getGroup() === $group) {
                return $controller;
            }
        }
    }