original_string: public function findPackage($search, $ignore_exception = false)
      {
          $search = strtolower($search);
  
          $found = $this->getRepositoryTheme($search);
          if ($found) {
              return $found;
          }
  
          $found = $this->getRepositoryPlugin($search);
          if ($found) {
              return $found;
          }
  
          $themes = $this->getRepositoryThemes();
          $plugins = $this->getRepositoryPlugins();
  
          if (!$themes && !$plugins) {
              if (!is_writable(ROOT_DIR . '/cache/gpm')) {
                  throw new \RuntimeException("The cache/gpm folder is not writable. Please check the folder permissions.");
              }
  
              if ($ignore_exception) {
                  return false;
              }
  
              throw new \RuntimeException("GPM not reachable. Please check your internet connection or check the Grav site is reachable");
          }
  
          if ($themes) {
              foreach ($themes as $slug => $theme) {
                  if ($search == $slug || $search == $theme->name) {
                      return $theme;
                  }
              }
          }
  
          if ($plugins) {
              foreach ($plugins as $slug => $plugin) {
                  if ($search == $slug || $search == $plugin->name) {
                      return $plugin;
                  }
              }
          }
  
          return false;
      }
code: public function findPackage($search, $ignore_exception = false)
      {
          $search = strtolower($search);
  
          $found = $this->getRepositoryTheme($search);
          if ($found) {
              return $found;
          }
  
          $found = $this->getRepositoryPlugin($search);
          if ($found) {
              return $found;
          }
  
          $themes = $this->getRepositoryThemes();
          $plugins = $this->getRepositoryPlugins();
  
          if (!$themes && !$plugins) {
              if (!is_writable(ROOT_DIR . '/cache/gpm')) {
                  throw new \RuntimeException("The cache/gpm folder is not writable. Please check the folder permissions.");
              }
  
              if ($ignore_exception) {
                  return false;
              }
  
              throw new \RuntimeException("GPM not reachable. Please check your internet connection or check the Grav site is reachable");
          }
  
          if ($themes) {
              foreach ($themes as $slug => $theme) {
                  if ($search == $slug || $search == $theme->name) {
                      return $theme;
                  }
              }
          }
  
          if ($plugins) {
              foreach ($plugins as $slug => $plugin) {
                  if ($search == $slug || $search == $plugin->name) {
                      return $plugin;
                  }
              }
          }
  
          return false;
      }
code_tokens: public function findPackage ( $ search , $ ignore_exception = false ) { $ search = strtolower ( $ search ) ; $ found = $ this -> getRepositoryTheme ( $ search ) ; if ( $ found ) { return $ found ; } $ found = $ this -> getRepositoryPlugin ( $ search ) ; if ( $ found ) { return $ found ; } $ themes = $ this -> getRepositoryThemes ( ) ; $ plugins = $ this -> getRepositoryPlugins ( ) ; if ( ! $ themes && ! $ plugins ) { if ( ! is_writable ( ROOT_DIR . '/cache/gpm' ) ) { throw new \ RuntimeException ( "The cache/gpm folder is not writable. Please check the folder permissions." ) ; } if ( $ ignore_exception ) { return false ; } throw new \ RuntimeException ( "GPM not reachable. Please check your internet connection or check the Grav site is reachable" ) ; } if ( $ themes ) { foreach ( $ themes as $ slug => $ theme ) { if ( $ search == $ slug || $ search == $ theme -> name ) { return $ theme ; } } } if ( $ plugins ) { foreach ( $ plugins as $ slug => $ plugin ) { if ( $ search == $ slug || $ search == $ plugin -> name ) { return $ plugin ; } } } return false ; }
docstring: Searches for a Package in the repository
  @param  string $search Can be either the slug or the name
  @param  bool $ignore_exception True if should not fire an exception (for use in Twig)
  @return Remote\Package|bool Package if found, FALSE if not
docstring_tokens: Searches for a Package in the repository