original_string: public function findFiles($searchTerm, $sortBy = 'title', $filter = null)
      {
          $words = explode(' ', Str::lower($searchTerm));
          $result = [];
  
          $findInFolder = function ($folder) use (&$findInFolder, $words, &$result, $sortBy, $filter) {
              $folderContents = $this->listFolderContents($folder, $sortBy, $filter);
  
              foreach ($folderContents as $item) {
                  if ($item->type == MediaLibraryItem::TYPE_FOLDER) {
                      $findInFolder($item->path);
                  }
                  elseif ($this->pathMatchesSearch($item->path, $words)) {
                      $result[] = $item;
                  }
              }
          };
  
          $findInFolder('/');
  
          /*
           * Sort the result
           */
  
          if ($sortBy !== false) {
              $this->sortItemList($result, $sortBy);
          }
  
          return $result;
      }
code: public function findFiles($searchTerm, $sortBy = 'title', $filter = null)
      {
          $words = explode(' ', Str::lower($searchTerm));
          $result = [];
  
          $findInFolder = function ($folder) use (&$findInFolder, $words, &$result, $sortBy, $filter) {
              $folderContents = $this->listFolderContents($folder, $sortBy, $filter);
  
              foreach ($folderContents as $item) {
                  if ($item->type == MediaLibraryItem::TYPE_FOLDER) {
                      $findInFolder($item->path);
                  }
                  elseif ($this->pathMatchesSearch($item->path, $words)) {
                      $result[] = $item;
                  }
              }
          };
  
          $findInFolder('/');
  
          /*
           * Sort the result
           */
  
          if ($sortBy !== false) {
              $this->sortItemList($result, $sortBy);
          }
  
          return $result;
      }
code_tokens: public function findFiles ( $ searchTerm , $ sortBy = 'title' , $ filter = null ) { $ words = explode ( ' ' , Str :: lower ( $ searchTerm ) ) ; $ result = [ ] ; $ findInFolder = function ( $ folder ) use ( & $ findInFolder , $ words , & $ result , $ sortBy , $ filter ) { $ folderContents = $ this -> listFolderContents ( $ folder , $ sortBy , $ filter ) ; foreach ( $ folderContents as $ item ) { if ( $ item -> type == MediaLibraryItem :: TYPE_FOLDER ) { $ findInFolder ( $ item -> path ) ; } elseif ( $ this -> pathMatchesSearch ( $ item -> path , $ words ) ) { $ result [ ] = $ item ; } } } ; $ findInFolder ( '/' ) ; /*
           * Sort the result
           */ if ( $ sortBy !== false ) { $ this -> sortItemList ( $ result , $ sortBy ) ; } return $ result ; }
docstring: Finds files in the Library.
  @param string $searchTerm Specifies the search term.
  @param mixed $sortBy Determines the sorting preference.
  Supported values are 'title', 'size', 'lastModified' (see SORT_BY_XXX class constants), FALSE (to disable sorting), or an associative array with a 'by' key and a 'direction' key: ['by' => SORT_BY_XXX, 'direction' => SORT_DIRECTION_XXX].
  @param string $filter Determines the document type filtering preference.
  Supported values are 'image', 'video', 'audio', 'document' (see FILE_TYPE_XXX constants of MediaLibraryItem class).
  @return array Returns an array of MediaLibraryItem objects.
docstring_tokens: Finds files in the Library .