original_string: public function groupUrlsByHost($siteUrls)
      {
          if (empty($siteUrls)) {
              return array();
          }
  
          $allUrls = array();
  
          foreach ($siteUrls as $idSite => $urls) {
              $idSite = (int) $idSite;
              foreach ($urls as $url) {
                  $urlParsed = @parse_url($url);
  
                  if ($urlParsed === false || !isset($urlParsed['host'])) {
                      continue;
                  }
  
                  $host = $this->toCanonicalHost($urlParsed['host']);
                  $path = $this->getCanonicalPathFromParsedUrl($urlParsed);
  
                  if (!isset($allUrls[$host])) {
                      $allUrls[$host] = array();
                  }
  
                  if (!isset($allUrls[$host][$path])) {
                      $allUrls[$host][$path] = array();
                  }
  
                  if (!in_array($idSite, $allUrls[$host][$path])) {
                      $allUrls[$host][$path][] = $idSite;
                  }
              }
          }
  
          foreach ($allUrls as $host => $paths) {
              uksort($paths, array($this, 'sortByPathDepth'));
              $allUrls[$host] = $paths;
          }
  
          return $allUrls;
      }
code: public function groupUrlsByHost($siteUrls)
      {
          if (empty($siteUrls)) {
              return array();
          }
  
          $allUrls = array();
  
          foreach ($siteUrls as $idSite => $urls) {
              $idSite = (int) $idSite;
              foreach ($urls as $url) {
                  $urlParsed = @parse_url($url);
  
                  if ($urlParsed === false || !isset($urlParsed['host'])) {
                      continue;
                  }
  
                  $host = $this->toCanonicalHost($urlParsed['host']);
                  $path = $this->getCanonicalPathFromParsedUrl($urlParsed);
  
                  if (!isset($allUrls[$host])) {
                      $allUrls[$host] = array();
                  }
  
                  if (!isset($allUrls[$host][$path])) {
                      $allUrls[$host][$path] = array();
                  }
  
                  if (!in_array($idSite, $allUrls[$host][$path])) {
                      $allUrls[$host][$path][] = $idSite;
                  }
              }
          }
  
          foreach ($allUrls as $host => $paths) {
              uksort($paths, array($this, 'sortByPathDepth'));
              $allUrls[$host] = $paths;
          }
  
          return $allUrls;
      }
code_tokens: public function groupUrlsByHost ( $ siteUrls ) { if ( empty ( $ siteUrls ) ) { return array ( ) ; } $ allUrls = array ( ) ; foreach ( $ siteUrls as $ idSite => $ urls ) { $ idSite = ( int ) $ idSite ; foreach ( $ urls as $ url ) { $ urlParsed = @ parse_url ( $ url ) ; if ( $ urlParsed === false || ! isset ( $ urlParsed [ 'host' ] ) ) { continue ; } $ host = $ this -> toCanonicalHost ( $ urlParsed [ 'host' ] ) ; $ path = $ this -> getCanonicalPathFromParsedUrl ( $ urlParsed ) ; if ( ! isset ( $ allUrls [ $ host ] ) ) { $ allUrls [ $ host ] = array ( ) ; } if ( ! isset ( $ allUrls [ $ host ] [ $ path ] ) ) { $ allUrls [ $ host ] [ $ path ] = array ( ) ; } if ( ! in_array ( $ idSite , $ allUrls [ $ host ] [ $ path ] ) ) { $ allUrls [ $ host ] [ $ path ] [ ] = $ idSite ; } } } foreach ( $ allUrls as $ host => $ paths ) { uksort ( $ paths , array ( $ this , 'sortByPathDepth' ) ) ; $ allUrls [ $ host ] = $ paths ; } return $ allUrls ; }
docstring: Groups all URLs by host, path and idsite.
  
  @param array $urls  An array containing URLs by idsite,
  eg array(array($idSite = 1 => array('apache.piwik', 'apache2.piwik'), 2 => array(), ...))
  as returned by {@link getAllCachedSiteUrls()} and {@link getAllSiteUrls}
  @return array All urls grouped by host => path => idSites. Path having the most '/' will be listed first
  array(
  'apache.piwik' => array(
  '/test/two' => $idsite = array(3),
  '/test' => $idsite = array(1),
  '/' => $idsite = array(2),
  ),
  'test.apache.piwik' => array(
  '/test/two' => $idsite = array(3),
  '/test' => $idsite = array(1),
  '/' => $idsite = array(2, 3),
  ),
  );
docstring_tokens: Groups all URLs by host path and idsite .