/** * @param $URL * @return mixed */ private function getContent($URL) { try { $idn = new IdnaConvert(array('idn_version' => 2008)); $url = $idn->encode($URL); $params = array('url' => $url, 'host' => '', 'header' => '', 'method' => 'GET', 'referer' => '', 'cookie' => '', 'post_fields' => '', 'timeout' => 20); $this->curl->init($params); $result = $this->curl->exec(); if ($result['curl_error']) { throw new \Exception($result['curl_error']); } if ($result['http_code'] != '200') { throw new \Exception("HTTP Code = " . $result['http_code']); } if (!$result['body']) { throw new \Exception("Body of file is empty"); } } catch (Exception $e) { echo $e->getMessage(); } return $result['body']; }
/** * @test */ public function urlDecode() { $idn = new IdnaConvert(array('idn_version' => 2008)); $url = $idn->encode('тестування.укр'); $this->assertEquals($url, 'xn--80adi8aaufcj8j.xn--j1amh'); }