original_string: public static function getIdSitesFromIdSitesString($ids, $_restrictSitesToLogin = false)
      {
          if ($ids === 'all') {
              return API::getInstance()->getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin);
          }
  
          if (is_bool($ids)) {
              return array();
          }
          if (!is_array($ids)) {
              $ids = explode(',', $ids);
          }
          $validIds = array();
          foreach ($ids as $id) {
              $id = trim($id);
              if (!empty($id) && is_numeric($id) && $id > 0) {
                  $validIds[] = $id;
              }
          }
          $validIds = array_filter($validIds);
          $validIds = array_unique($validIds);
  
          return $validIds;
      }
code: public static function getIdSitesFromIdSitesString($ids, $_restrictSitesToLogin = false)
      {
          if ($ids === 'all') {
              return API::getInstance()->getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin);
          }
  
          if (is_bool($ids)) {
              return array();
          }
          if (!is_array($ids)) {
              $ids = explode(',', $ids);
          }
          $validIds = array();
          foreach ($ids as $id) {
              $id = trim($id);
              if (!empty($id) && is_numeric($id) && $id > 0) {
                  $validIds[] = $id;
              }
          }
          $validIds = array_filter($validIds);
          $validIds = array_unique($validIds);
  
          return $validIds;
      }
code_tokens: public static function getIdSitesFromIdSitesString ( $ ids , $ _restrictSitesToLogin = false ) { if ( $ ids === 'all' ) { return API :: getInstance ( ) -> getSitesIdWithAtLeastViewAccess ( $ _restrictSitesToLogin ) ; } if ( is_bool ( $ ids ) ) { return array ( ) ; } if ( ! is_array ( $ ids ) ) { $ ids = explode ( ',' , $ ids ) ; } $ validIds = array ( ) ; foreach ( $ ids as $ id ) { $ id = trim ( $ id ) ; if ( ! empty ( $ id ) && is_numeric ( $ id ) && $ id > 0 ) { $ validIds [ ] = $ id ; } } $ validIds = array_filter ( $ validIds ) ; $ validIds = array_unique ( $ validIds ) ; return $ validIds ; }
docstring: Checks the given string for valid site IDs and returns them as an array.
  
  @param string|array $ids Comma separated idSite list, eg, `'1,2,3,4'` or an array of IDs, eg,
  `array(1, 2, 3, 4)`.
  @param bool|string $_restrictSitesToLogin Implementation detail. Used only when running as a scheduled task.
  @return array An array of valid, unique integers.
docstring_tokens: Checks the given string for valid site IDs and returns them as an array .