filterList() protected method

This method returns the IdPs that comply with the following conditions: - The IdP does not have the 'hide.from.discovery' configuration option.
protected filterList ( array $list ) : array
$list array An associative array containing metadata for the IdPs to apply the filtering to.
return array An associative array containing metadata for the IdPs that were not filtered out.
 /**
  * Filter a list of entities according to any filters defined in the parent class, plus discopower configuration
  * options regarding filtering.
  *
  * @param array $list A list of entities to filter.
  *
  * @return array The list in $list after filtering entities.
  */
 protected function filterList($list)
 {
     parent::filterList($list);
     try {
         $spmd = $this->metadata->getMetaData($this->spEntityId, 'saml20-sp-remote');
     } catch (Exception $e) {
         return $list;
     }
     if (!isset($spmd)) {
         return $list;
     }
     if (!array_key_exists('discopower.filter', $spmd)) {
         return $list;
     }
     $filter = $spmd['discopower.filter'];
     if (!array_key_exists('entities.include', $filter)) {
         $filter['entities.include'] = array();
     }
     if (!array_key_exists('entities.exclude', $filter)) {
         $filter['entities.exclude'] = array();
     }
     if (!array_key_exists('tags.include', $filter)) {
         $filter['tags.include'] = array();
     }
     if (!array_key_exists('tags.exclude', $filter)) {
         $filter['tags.exclude'] = array();
     }
     $defaultrule = true;
     if (array_key_exists('entities.include', $spmd['discopower.filter']) || array_key_exists('tags.include', $spmd['discopower.filter'])) {
         $defaultrule = false;
     }
     $returnlist = array();
     foreach ($list as $key => $entry) {
         if ($this->processFilter($filter, $entry, $defaultrule)) {
             $returnlist[$key] = $entry;
         }
     }
     return $returnlist;
 }