Merge "Do not pass unused parameter"
[lhc/web/wiklou.git] / includes / search / SearchSuggestionSet.php
index ab38420..f1da246 100644 (file)
@@ -80,13 +80,25 @@ class SearchSuggestionSet {
 
        /**
         * Call array_map on the suggestions array
-        * @param callback $callback
+        * @param callable $callback
         * @return array
         */
        public function map( $callback ) {
                return array_map( $callback, $this->suggestions );
        }
 
+       /**
+        * Filter the suggestions array
+        * @param callable $callback Callable accepting single SearchSuggestion
+        *  instance returning bool false to remove the item.
+        * @return int The number of suggestions removed
+        */
+       public function filter( $callback ) {
+               $before = count( $this->suggestions );
+               $this->suggestions = array_values( array_filter( $this->suggestions, $callback ) );
+               return $before - count( $this->suggestions );
+       }
+
        /**
         * Add a new suggestion at the end.
         * If the score of the new suggestion is greater than the worst one,