headers = $headers; $this->ip = $ip; } public static function createFromString($string, $ip) { $data = explode("\r\n", trim($string)); $status = array_shift($data); $headers = []; foreach ($data as $line) { list ($header, $value) = array_map("trim", explode(":",$line,2)); $headers[strtolower($header)] = $value; } // Test for search responses using the ST header if (array_key_exists('st', $headers)) { return new MSearchResponse($headers, $ip); } } public function getIp() { return $this->ip; } public function getLocation() { return $this->headers['location']; } }