public function testFetch() { $fetcher = new WebServiceFetcher('https://www.google.com/s2/favicons?domain='); $destination = __DIR__ . '/../Resources/new_default_favicon.png'; $generated = $fetcher->fetch('http://github.com', $destination); $this->assertTrue($generated); $this->assertTrue(file_exists($destination)); }
/** * @inheritdoc */ public function fetch($url, $destination) { /* needs fully quallified url e.q with http:// */ if ($this->skipDefaultImage) { $url .= '?defaulticon=none'; // none: no default icon will be returned (and an HTTP 204 "No content" response code) } try { $ch = parent::fetch($url, $destination); if ($ch && $this->converter) { //convert to png return $this->converter->convert($destination); } return $ch; } catch (\Exception $e) { // hmm ok, let the next Fetcher try its luck } return null; }