public function testGet()
 {
     $resolver = new DomainFileNameResolver();
     $generated = $resolver->get('http://github.com');
     $this->assertEquals('github.com', $generated);
     $generated = $resolver->get('github.com');
     $this->assertEquals('github.com', $generated);
     $generated = $resolver->get('https://github.com/users/ivoba');
     $this->assertEquals('github.com', $generated);
     $resolver = new DomainFileNameResolver($prefix = 'favicon.', $suffix = '.png');
     $generated = $resolver->get('http://github.com');
     $this->assertEquals('favicon.github.com.png', $generated);
     $generated = $resolver->get('github.com');
     $this->assertEquals('favicon.github.com.png', $generated);
     $generated = $resolver->get('https://github.com/users/ivoba');
     $this->assertEquals('favicon.github.com.png', $generated);
 }
示例#2
0
 /**
  * @param array $urls
  * @return array
  */
 public function fetch(array $urls)
 {
     $images = [];
     foreach ($urls as $url) {
         $name = $this->fileNameResolver->get($url);
         if ($name) {
             $destination = $this->imageDir . $name;
             foreach ($this->fetchers as $fetcher) {
                 $favicon = $fetcher->fetch($url, $destination);
                 if ($favicon) {
                     $images[$url] = $destination;
                     break;
                 }
             }
         }
     }
     return $images;
 }